Advertisement
welleyth

1284. Honeycomb Walk

Dec 27th, 2020
1,218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define mp make_pair
  7. #define pb push_back
  8.  
  9. const int N = 60;
  10. const int MOVES = 15;
  11. const int INF = (int)1e18;
  12.  
  13. int dp[N][N][MOVES]={};
  14.  
  15. signed main()
  16. {
  17.     ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  18.     //freopen("input.txt","r",stdin);
  19.     //freopen("output.txt","w",stdout);
  20.  
  21.     dp[30][30][0]=1;
  22.  
  23.     for(int step=1;step<15;step++)
  24.     {
  25.         for(int x=15;x<=45;x++)
  26.         {
  27.             for(int y=15;y<=45;y++)
  28.             {
  29.                 dp[x][y][step] = dp[x][y-1][step-1] + dp[x-1][y][step-1]
  30.                                + dp[x-1][y-1][step-1] + dp[x][y+1][step-1]
  31.                                + dp[x+1][y][step-1] + dp[x+1][y+1][step-1];
  32.             }
  33.         }
  34.     }
  35.  
  36.     int t;
  37.     cin >> t;
  38.  
  39.     while(t--)
  40.     {
  41.         int a;
  42.         cin >> a;
  43.         cout << dp[30][30][a] << "\n";
  44.     }
  45.  
  46.     return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement