Divide Chocolate

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1632    Accepted Submission(s): 765

Problem Description
It is well known that claire likes dessert very much, especially chocolate. But as a girl she also focuses on the intake of calories each day. To satisfy both of the two desires, claire makes a decision that each chocolate should be divided into several parts, and each time she will enjoy only one part of the chocolate. Obviously clever claire can easily accomplish the division, but she is curious about how many ways there are to divide the chocolate.

To simplify this problem, the chocolate can be seen as a rectangular contains n*2 grids (see above). And for a legal division plan, each part contains one or more grids that are connected. We say two grids are connected only if they share an edge with each other or they are both connected with a third grid that belongs to the same part. And please note, because of the amazing craft, each grid is different with others, so symmetrical division methods should be seen as different.
 
Input
First line of the input contains one integer indicates the number of test cases. For each case, there is a single line containing two integers n (1<=n<=1000) and k (1<=k<=2*n).n denotes the size of the chocolate and k denotes the number of parts claire wants to divide it into.
 
Output
For each case please print the answer (the number of different ways to divide the chocolate) module 100000007 in a single line.�
 
Sample Input
2
2 1
5 2
 
Sample Output
1
45
 

 题目大意:给你一块2*n的巧克力,求把它切成k块的切法。

 #include<iostream>
#include<cstdio>
using namespace std; const int M=;
int d[][][]={};
//i表示第i列,j表示分成j个,k表示最后一列的两种状态
//0表示最后一列分成一块,1表示分成两块 void init()
{
int i,j;
d[][][]=;d[][][]=;
for(i=;i<=;i++)
{
for(j=;j<=*i;j++)
{
d[i][j][]=(d[i-][j][]+*d[i-][j][]+d[i-][j-][]+d[i-][j-][])%M;
d[i][j][]=(d[i-][j][]+*d[i-][j-][]+*d[i-][j-][]+d[i-][j-][]+d[i-][j-][])%M;
}
}
}
int main()
{
int n,k,t;
init();
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&n,&k);
printf("%d\n",(d[n][k][]+d[n][k][])%M);
}
return ;
}

hdu 4301 dp的更多相关文章

  1. hdu 3016 dp+线段树

    Man Down Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  2. HDU 5928 DP 凸包graham

    给出点集,和不大于L长的绳子,问能包裹住的最多点数. 考虑每个点都作为左下角的起点跑一遍极角序求凸包,求的过程中用DP记录当前以j为当前末端为结束的的最小长度,其中一维作为背包的是凸包内侧点的数量.也 ...

  3. HDU 4301 Divide Chocolate(DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=4301 题意: 有一块n*2大小的巧克力,现在某人要将这巧克力分成k个部分,每个部分大小随意,问有多少种分法. 思 ...

  4. hdu 4301(基本dp)

    题意:就是给你一块2*n的巧克力,让你把它分成x块,并且每一个单位的巧克力各不相同,问有多少种分法? 分析:用dp[i][j][k],表示到巧克力的第二列时,巧克力被分成了j快,k用来表示第i列上下两 ...

  5. HDU 4301 Divide Chocolate (DP + 递推)

    Divide Chocolate Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  6. HDU 1069 dp最长递增子序列

    B - Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  7. HDU 1160 DP最长子序列

    G - FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  8. hdu 4826(dp + 记忆化搜索)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4826 思路:dp[x][y][d]表示从方向到达点(x,y)所能得到的最大值,然后就是记忆化了. #i ...

  9. HDU 2861 (DP+打表)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2861 题目大意:n个位置,m个人,分成k段,统计分法.S(n)=∑nk=0CknFibonacci(k ...

随机推荐

  1. Shell脚本调用ftp上传文件

    Shell脚本调用ftp上传文件 1.脚本如下 ftp -n<<! open x.x.x.x ###x.x.x.x为ftp地址 user username password ###user ...

  2. ssh整合思想 Spring与Hibernate的整合 项目在服务器启动则自动创建数据库表

    Spring整合Hibernate Spring的Web项目中,web.xml文件会自动加载,以出现欢迎首页.也可以在这个文件中对Spring的配置文件进行监听,自启动配置文件, 以及之前Struts ...

  3. 【线段树 泰勒展开】Codechef April Challenge 2018 Chef at the Food Fair

    第一次写泰勒展开:本地和CC差距好大 题目大意 大厨住的城市里办了一场美食节.一条街上开设了$N$个摊位,编号为$1∼N$.这天开始时,第$i$个摊位的食物会导致食物中毒的概率是$P_i$.在这一天中 ...

  4. 02等待单个线程返回WaitForSingleObject

    windows 多线程之等待线程返回 ​ 多线程编程中,有时我们需要等待某一线程完成了特定的操作之后再继续做其他事情,要实现这个目的,可以使用 Windows API 函数 WaitForSingle ...

  5. linux关于任务计划

    1.一次性任务计划:at 1)添加 在18:16时候重启服务器 at 18:16 >at init 6 >at ctrl+d2)查看 atq 1 Mon Aug 20 21:09:00 2 ...

  6. 【jenkins】jenkins执行nohup java报错

    nohup:failed to run command 'java':No such file or directory 这是因为jenkins只认绝对路径.在shell里面有涉及到文件的都应该写成绝 ...

  7. windows server 服务器 环境配置

    自动备份 xcopy d:\web\zhiku\*.* d:\bak\web\zhiku\%date:~,4%%date:~5,2%%date:~8,2%\ /S /I

  8. Survey lists 10 most innovative cities

    From China Daily Beijing and Shanghai are among the 10 most innovative cities in the world, based on ...

  9. 数学基础:HUD1406-完数

    完数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Descript ...

  10. bash实例-参数/函数/统计IP

    1.写一个脚本getinterface.sh,脚本可以接受参数(i,I,a),完成以下任务:   (1)使用以下形式:getinterface.sh [-i interface|-I IP|-a]  ...