hdu 2323 Honeycomb Walk
2014-08-06 20:09
316 查看
[align=left]Problem Description[/align]
A bee larva living in a hexagonal cell of a large honeycomb decides to creep for a walk. In each “step” the larva may move into any of the six adjacent cells and after n steps, it is to end up in its original
cell.
Your program has to compute, for a given n, the number of different such larva walks.
[align=left]Input[/align]
The first line contains an integer giving the number of test cases to follow. Each case consists of one line containing an integer n, where 1 ≤ n ≤ 14.
[align=left]Output[/align]
For each test case, output one line containing the number of walks. Under the assumption 1 ≤ n ≤ 14, the answer will be less than 231 - 1.
[align=left]Sample Input[/align]
[align=left]Sample Output[/align]
A bee larva living in a hexagonal cell of a large honeycomb decides to creep for a walk. In each “step” the larva may move into any of the six adjacent cells and after n steps, it is to end up in its original
cell.
Your program has to compute, for a given n, the number of different such larva walks.
[align=left]Input[/align]
The first line contains an integer giving the number of test cases to follow. Each case consists of one line containing an integer n, where 1 ≤ n ≤ 14.
[align=left]Output[/align]
For each test case, output one line containing the number of walks. Under the assumption 1 ≤ n ≤ 14, the answer will be less than 231 - 1.
[align=left]Sample Input[/align]
2 2 4
[align=left]Sample Output[/align]
6 90带点搜索意味的dp#include<iostream> #include<cstring> using namespace std; int dp[17][30][30],p=15,q=15; int to[6][2]={1,0,-1,0,1,1,0,1,-1,-1,0,-1}; int main() { int i,j,k,l,t,n; memset(dp,0,sizeof dp); dp[0][p][q]=1; for(i=1;i<15;i++) { for(j=0;j<30;j++) { for(k=0;k<30;k++) { for(l=0;l<6;l++) { int r=j+to[l][0]; int c=k+to[l][1]; dp[i][j][k]+=dp[i-1][r][c]; } } } } cin>>t; while(t--) { cin>>n; cout<<dp [p][q]<<endl;; } return 0; }
相关文章推荐
- HDU 2323 Honeycomb Walk
- HDU--杭电--2323--Honeycomb Walk--DP
- A Walk Through the Forest HDU - 1142
- HDU 4487 Maximum Random Walk
- 【HDU】1142 A Walk Through the Forest 最短路+记忆化搜索
- HDU 5001 Walk(2014年鞍山赛区网络赛E题)
- hdu 1142 A Walk Through the Forest (最短路+dfs )
- hdu 1142/hrbust 1347 A Walk Through the Forest/森林中的路【SPFA+记忆化搜索】
- hdu1142-A Walk Through the Forest-最短路+dfs
- HDU 1142 A Walk Through the Forest 最短路+记忆搜索
- hdu 4487 Maximum Random Walk(概率dp)
- zoj 2546 || poj 2662 || hdu 1142 A Walk Through the Forest
- HDU 1142 A Walk Through the Forest (dijkstra算法)
- hdu 4487 Maximum Random Walk
- Hdu 1142 A Walk Through the Forest
- HDU - 4758 Walk Through Squares (AC自动机+DP)
- Hdu 4487 Maximum Random Walk
- hdu 5001 Walk(概率dp+搜索,矩阵快速幂)
- hdu 1142 A Walk Through the Forest 最短路
- HDU 1142 A Walk Through the Forest(spfa最短路+dfs记忆化搜索)