Divide Chocolate

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

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
 
Author
BUPT
 
Source
 
Recommend
     给你一个2*n的矩阵分成k部分的数目求余....
    思路:dp1[n][m]前N列分成M份,最后两个分开的情况数  (看到某位大牛的思路写的...)

dp2[n][m]前N列分成M份,最后两个在一起断情况

   
代码:

 #include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=;
const LL mod=;
LL dp1[][maxn],dp2[][maxn];
int main()
{
memset(dp1,,sizeof(dp1));
memset(dp2,,sizeof(dp2));
dp1[][]=;dp1[][]=;
dp2[][]=;dp2[][]=;
for(int i=;i<=;++i)
for(int j=;j<=i+i;++j)
{
dp1[i][j]=dp1[i-][j]+dp1[i-][j-]*+dp2[i-][j-]*;
if(j>)
dp1[i][j]+=dp1[i-][j-]+dp2[i-][j-];
dp1[i][j]%=mod;
dp2[i][j]=dp1[i-][j]*+dp2[i-][j]+dp1[i-][j-]+dp2[i-][j-];
dp2[i][j]%=mod;
}
int test;
scanf("%d",&test);
while(test--){
int a,b;
scanf("%d%d",&a,&b);
printf("%lld\n",(dp1[a][b]+dp2[a][b])%mod);
}
return ;
}

hdu----(4301)Divide Chocolate(状态打表)的更多相关文章

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

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

  2. HDU 4301 Divide Chocolate(DP)

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

  3. hdu 4301 dp

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

  4. HDU 5783 Divide the Sequence(数列划分)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  5. HDU 4548 美素数(打表)

    HDU  4548  美素数(打表)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88159#problem/H 题目 ...

  6. [记录]Zabbix3.4配置监控Oracle12c的存活状态和表空间使用率

    Zabbix3.4配置监控Oracle的存活状态和表空间使用率 1.安装zabbix3.4 agent: # rpm -ivh http://repo.zabbix.com/zabbix/3.4/rh ...

  7. hdu 4352 数位dp + 状态压缩

    XHXJ's LIS Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  8. [转]查看处于被锁状态的表:v$locked_object dba_objects v$session all_objects v$sqlarea v$lock

    oracle官网当一个用户发出select..for update的错作准备对返回的结果集进行修改时,如果结果集已经被另一个会话锁定,就是发生阻塞.需要等另一个会话结束之后才可继续执行.可以通过发出 ...

  9. C/C++用状态转移表联合函数指针数组实现状态机FSM

    状态机在project中使用很的频繁,有例如以下常见的三种实现方法: 1. switch-case 实现.适合简单的状态机. 2. 二维状态表state-event实现.逻辑清晰.可是矩阵通常比較稀疏 ...

随机推荐

  1. External Storage 数据存储

    一些数据存储的封装:http://hubingforever.blog.163.com/blog/static/17104057920129198236599/ External Storage数据存 ...

  2. window server开发

    代码部分: public partial class tv : ServiceBase { public tv() { InitializeComponent(); ServiceName = &qu ...

  3. jquery之 off()方法

    off()函数用于移除元素上绑定的一个或多个事件的事件处理函数. off()函数主要用于解除由on()函数绑定的事件处理函数. 该函数属于jQuery对象(实例). 语法 jQuery 1.7 新增该 ...

  4. Quartz:ERROR threw an unhandled Exception

    详细的错误信息如下: -- ::] ERROR org.quartz.core.JobRunShell: - Job group1.job1 threw an unhandled Exception: ...

  5. 再论EM算法的收敛性和K-Means的收敛性

    标签(空格分隔): 机器学习 (最近被一波波的笔试+面试淹没了,但是在有两次面试时被问到了同一个问题:K-Means算法的收敛性.在网上查阅了很多资料,并没有看到很清晰的解释,所以希望可以从K-Mea ...

  6. 统计map上的read数量

    samtools flagstat /SRA111111/SRR111222/accepted_hits.bam 78406056 + 0 in total (QC-passed reads + QC ...

  7. [SAP ABAP开发技术总结]屏幕跳转

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  8. iOS适配(Masonry)

    1.各屏幕大小 设备 尺寸 像素 点 iPhone \ iPhone 3G \ iPhone 3GS 3.5 inch 320 x 480 320 x 480 iPhone 4 \ iPhone 4S ...

  9. 10款Windows命令行工具

    Windows下CMD不好用,远没有Linux,或者一些SSH工具用起来方便.其实Windows下,也有一些不错的工具替代CMD: 0.powercmd经过比较,我最终选择了这款,这里补充一下截图:

  10. poj1474Video Surveillance(半平面交)

    链接 半平面交的模板题,判断有没有核.: 注意一下最后的核可能为一条线,面积也是为0的,但却是有的. #include<iostream> #include <stdio.h> ...