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. tcpdump命令使用方法

    NAME tcpdump - 转储网络上的数据流 总 tcpdump [ -adeflnNOpqStvx ] [ -c count ] [ -F file ] [ -i interface ] [ - ...

  2. h5移动端混编总结

    1.通信机制:解决是否能通信的问题: 2.接口:解决调用会话问题: 3.数据.URL正确性:解决数据.URL跳转路径正确性问题.

  3. C_动态库|静态库

    动态库 动态链接库简称DLL,同时以.dll 为后缀,主要用于提供代码和数据 dll 并不是所有数据都能被访问到,必须要进行导出 动态链接库在内存中始终只保存了一份数据,起到了节约内存的作用 生成动态 ...

  4. Mybatis与Spring整合方法

    实现mybatis与spring进行整合,通过spring管理SqlSessionFactory.mapper接口. tips:mybatis官方提供与mybatis与spring整合jar包. 一. ...

  5. Invalid ON UPDATE clause for 'create_date' column

    高版本的mysql导数据到低版本出现的问题 日期类型报错 解决方式:将datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT  中的  ON ...

  6. Android 项目Log日志输出优化

    概述 Android开发过程中经常需要向控制台输出日志信息,有些人还在用Log.i(tag,msg)的形式或者system.out.println(msg)方式吗?本篇文章对日志信息输出进行优化,以达 ...

  7. datatable 分组

    public static void PrintPersons() { //准备数据 DataTable dt = new DataTable(); dt.Columns.Add(new DataCo ...

  8. 洛谷——P2054 [AHOI2005]洗牌(扩展欧几里得,逆元)

    P2054 [AHOI2005]洗牌 扩展欧拉定理求逆元 $1 2 3 4 5 6$$4 1 5 2 6 3$$2 4 6 1 3 5$$1 2 3 4 5 6$ 手推一下样例,你就会发现是有规律的: ...

  9. CentOS7.x的DNS服务的基础配置

    一.bind服务器安装 bind:开源.稳定.应用广泛的DNS服务.bind的软件包名bind,服务名称named. 查看是否安装bind, 安装bind包: rpm -qa bind yum -y ...

  10. 爬虫之Selenium库

    官方文档:https://selenium-python.readthedocs.io/ Selenium:自动化测试工具,支持多种浏览器.爬虫中主要用来解决JavaScript渲染的问题. 一.开始 ...