A bee larva living in a hexagonal cell of a large honey comb 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.

Input

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. SAMPLE INPUT
2
2
4

Output

For each test case, output one line containing the number of walks. Under the
assumption 1 ≤ n ≤ 14, the answer will be less than 2^31. SAMPLE OUTPUT
6
90

dp

/* ***********************************************
Author :guanjun
Created Time :2016/10/5 13:32:45
File Name :spojMBEEWALK.cpp
************************************************ */
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
ll dp[][][];
//第i步 到达位置 j k的方案数
int dir[][]={
,,-,,,,,-,,-,-,
};
void init(){
cle(dp);
dp[][][]=;
for(int i=;i<=;i++){
for(int x=;x<=;x++){
for(int y=;y<=;y++){
for(int j=;j<;j++){
int nx=x+dir[j][];
int ny=y+dir[j][];
dp[i][x][y]+=dp[i-][nx][ny];
}
}
}
}
} int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int t,n;
init();
cin>>t;
while(t--){
cin>>n;
if(n==)puts("");
else{
cout<<dp[n][][]<<endl;
}
}
return ;
}
A bee larva living in a hexagonal cell of a large honey comb 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.

Input

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. SAMPLE INPUT
2
2
4

Output

For each test case, output one line containing the number of walks. Under the
assumption 1 ≤ n ≤ 14, the answer will be less than 2^31. SAMPLE OUTPUT
6
90

MBEEWALK - Bee Walk的更多相关文章

  1. BZOJ1695 : [Usaco2007 Demo]Walk the Talk

    观察单词表可以发现: 对于长度为3的单词,前两个字母相同的单词不超过7个 对于长度为4的单词,前两个字母相同的单词不超过35个 于是首先$O(26*26*nm)$预处理出 s1[x][i][j]表示( ...

  2. BZOJ 1695 [Usaco2007 Demo]Walk the Talk 链表+数学

    题意:链接 方法:乱搞 解析: 出这道题的人存心报复社会. 首先这个单词表-先上网上找这个单词表- 反正总共2265个单词.然后就考虑怎么做即可了. 刚開始我没看表,找不到怎么做,最快的方法我也仅仅是 ...

  3. python os.walk()

    os.walk()返回三个参数:os.walk(dirpath,dirnames,filenames) for dirpath,dirnames,filenames in os.walk(): 返回d ...

  4. LYDSY模拟赛day1 Walk

    /* 依旧考虑新增 2^20 个点. i 只需要向 i 去掉某一位的 1 的点连边. 这样一来图的边数就被压缩到了 20 · 2^20 + 2n + m,然后 BFS 求出 1 到每个点的最短路即可. ...

  5. How Google TestsSoftware - Crawl, walk, run.

    One of the key ways Google achievesgood results with fewer testers than many companies is that we ra ...

  6. poj[3093]Margaritas On River Walk

    Description One of the more popular activities in San Antonio is to enjoy margaritas in the park alo ...

  7. os.walk()

    os.walk() 方法用于通过在目录树种游走输出在目录中的文件名,向上或者向下. walk()方法语法格式如下: os.walk(top[, topdown=True[, onerror=None[ ...

  8. bee使用

    beego虽然是一个简单的框架,但是其中用到了很多第三方的包,所以在你安装beego的过程中Go会自动安装其他关联的包. 当然第一步你需要安装Go,如何安装Go请参考我的书 安装beego go ge ...

  9. 使用bee自动生成api文档

    beego中的bee工具可以方便的自动生成api文档,基于数据库字段,自动生成golang版基于beego的crud代码,方法如下: 1.进入到gopath目录的src下执行命令: bee api a ...

随机推荐

  1. 【笔记JS/HTML/CSS】CSS3实现鼠标滑动显示动画(transition、transform)

    内容中包含 base64string 图片造成字符过多,拒绝显示

  2. Container Views

    https://developer.apple.com/documentation/uikit/views_and_controls Container Views Organize and pres ...

  3. VC++代码转换为QT代码问题总结

    一边开发一边总结......  QQ937113547

  4. ruby学习之路(一)

    学习ruby最好的方法就是下载源码包,里面带有sample和test,是入门学习的最好实例. 我下载的是2.1.0版本,首先./configure,然后make,sudo make install.从 ...

  5. 关押罪犯 - 并查集&优先队列

    题目地址:http://www.51cpc.com/web/problem.php?id=4261 Summarize: 此题最巧妙的是“敌人的敌人就是朋友!”,故需先将敌对关系放入优先队列,按怨恨值 ...

  6. [bzoj1569][JSOI2008][Blue Mary的职员分配]

    Description 由于Blue Mary呕心沥血的管理,Blue Mary的网络公司蒸蒸日上.现在一共拥有了n名职员,可惜没有任何的金钱和声誉.平均每名每天职员都可以给公司带来x单位金钱或者y单 ...

  7. Springboot源码分析

    参考资料 https://www.cnblogs.com/lizongshen/p/9127999.html

  8. 【OpenCV, MFC】利用MFC和OpenCV通过系统对话框打开和保存图片

    打开图片: void CImageProDlg::OnImageopen() { // TODO: 在此添加命令处理程序代码 Invalidate(); CFileDialog dlg(TRUE, N ...

  9. 基于XML文档的声明式事务配置

    <!-- 配置事务切面 --> <aop:config> <aop:pointcut expression="execution(* com.atguigu.t ...

  10. mysql 查询出的数组为null怎么转换成0

    mysql 查询出的数组为null怎么转换成0 IFNULL(b.dayPay,0) as yesterdayPay,