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. Dev

    调用DoValidate()始终返回true 解决方案 txtCarNo.IsModified = true; result = result & txtCarNo.DoValidate(); ...

  2. ERROR 1044 (42000) ERROR 1142 (42000): SELECT command denied to user ''@'localhost' for table 'user'

    ERROR: Access denied for user 'root'@'localhost' (using password: NO)    发现:    mysql -u root@localh ...

  3. linux下inotify的使用

    有时候我们需要检测某个目录下文件或者子目录的改动状况,如添加.删除.以及更新等,Linux系统上提供了inotify来完成这个功能.inotify是在版本2.6.13的内核中首次出现,现在的发行本应该 ...

  4. CUBRID学习笔记 6 修改用户密码

    修改密码 可以在web管理中修改. 还有另外两种体位 1  语句 ALTER USER user_name PASSWORD 'any_password_here_in_single_quotes'; ...

  5. BerkeleyDB 多索引查询

    由于性能原因,我们打算将关系型数据库转移到内存数据库中:在内存数据库产品的选型中,我们确定的候选对象有Redis和Berkeley DB: Redis查询效率不错,并且支持丰富的数据存储结构,但不支持 ...

  6. Perfection Kills

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  7. [转]-用Gradle 构建你的android程序

    出处:http://www.cnblogs.com/youxilua  前言 android gradle 的插件终于把混淆代码的task集成进去了,加上最近,android studio 用的是gr ...

  8. 关于inline-block 元素之间为何会产生间隔

    关于inline-block 元素之间为何会产生间隔 现象: <body> <input type="text"> <input type=" ...

  9. jj前端项目1th总结

    1:设计图--->分出几个独立模块--->颗粒化布局--->文档流控制整体布局--->固定位置的元素绝对定位,段落这种元素不可绝对定位.----->加上和后台交互用的js ...

  10. 使用phpmaill发送邮件的例子

    首先,要下载php_mail软件包 核心代码: index.php <?php include "mail.php"; if (!empty($_POST['to']) &a ...