MBEEWALK - Bee Walk
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的更多相关文章
- BZOJ1695 : [Usaco2007 Demo]Walk the Talk
观察单词表可以发现: 对于长度为3的单词,前两个字母相同的单词不超过7个 对于长度为4的单词,前两个字母相同的单词不超过35个 于是首先$O(26*26*nm)$预处理出 s1[x][i][j]表示( ...
- BZOJ 1695 [Usaco2007 Demo]Walk the Talk 链表+数学
题意:链接 方法:乱搞 解析: 出这道题的人存心报复社会. 首先这个单词表-先上网上找这个单词表- 反正总共2265个单词.然后就考虑怎么做即可了. 刚開始我没看表,找不到怎么做,最快的方法我也仅仅是 ...
- python os.walk()
os.walk()返回三个参数:os.walk(dirpath,dirnames,filenames) for dirpath,dirnames,filenames in os.walk(): 返回d ...
- LYDSY模拟赛day1 Walk
/* 依旧考虑新增 2^20 个点. i 只需要向 i 去掉某一位的 1 的点连边. 这样一来图的边数就被压缩到了 20 · 2^20 + 2n + m,然后 BFS 求出 1 到每个点的最短路即可. ...
- How Google TestsSoftware - Crawl, walk, run.
One of the key ways Google achievesgood results with fewer testers than many companies is that we ra ...
- poj[3093]Margaritas On River Walk
Description One of the more popular activities in San Antonio is to enjoy margaritas in the park alo ...
- os.walk()
os.walk() 方法用于通过在目录树种游走输出在目录中的文件名,向上或者向下. walk()方法语法格式如下: os.walk(top[, topdown=True[, onerror=None[ ...
- bee使用
beego虽然是一个简单的框架,但是其中用到了很多第三方的包,所以在你安装beego的过程中Go会自动安装其他关联的包. 当然第一步你需要安装Go,如何安装Go请参考我的书 安装beego go ge ...
- 使用bee自动生成api文档
beego中的bee工具可以方便的自动生成api文档,基于数据库字段,自动生成golang版基于beego的crud代码,方法如下: 1.进入到gopath目录的src下执行命令: bee api a ...
随机推荐
- R语言学习 - 箱线图(小提琴图、抖动图、区域散点图)
箱线图 箱线图是能同时反映数据统计量和整体分布,又很漂亮的展示图.在2014年的Nature Method上有2篇Correspondence论述了使用箱线图的好处和一个在线绘制箱线图的工具.就这样都 ...
- java.lang.NoClassDefFoundError: org/hibernate/validator/internal/engine/DefaultClockProvider
①在springboot的spring-boot-starter-web默认引入了以下依赖: <dependency> <groupId>com.fasterxml.jacks ...
- Spring框架系列(一)--Spring MVC基础知识
Web项目开发过程中一般都是使用MVC(Model-View-Controller)模式,早先的Struts2到Spring MVC,再到现在Spring Boot,都是相似的思 路.Spring B ...
- vue组件---动态组件之多标签页面
首先看下效果图 代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> & ...
- localStorage前端存储数据
<!DOCTYPE html> <html> <head> <title>localStorage演示</title> <meta c ...
- 深入分析同步工具类之CountDownLatch
概览: CountDownLatch又称闭锁,其作用是让一个或者多个线程挂起,直到其他的线程执行完后恢复挂起的线程,使其继续执行.内部维护着一个静态内部类Sync,该类继承AbstractQueued ...
- Python使用Flask框架,结合Highchart处理csv数据(引申-从文件获取数据--从数据库获取数据)
参考链接:https://www.highcharts.com.cn/docs/process-text-data-file 1.javascript代码 var options = { chart: ...
- 洛谷 2173 BZOJ 2816 [ZJOI2012]网络
[题解] 明显的LCT模板题,c种颜色就开c棵LCT好了.. #include<cstdio> #include<algorithm> #define N 100010 #de ...
- 【Codeforces 992B】Nastya Studies Informatics
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 因为gcd(a,b)=x 所以设a = nx b = mx 又有ab/gcd(a,b)=lcm(a,b)=y 则nmx = y 即n(m*x) ...
- [K/3Cloud] K/3 Cloud1.0怎样和2.0共存在一台服务器上
第一步:安装Cloud1.0,创建管理中心,创建业务数据中心,备份管理数据库和业务数据库,并且备份安装目录: 第二步:卸载Cloud1.0,清理安装目录,安装Cloud2.0,创建管理中心,创建业务数 ...