hdu----(4301)Divide Chocolate(状态打表)
Divide Chocolate
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1757 Accepted Submission(s): 827
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.
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.
2 1
5 2
45
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(状态打表)的更多相关文章
- HDU 4301 Divide Chocolate (DP + 递推)
Divide Chocolate Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 4301 Divide Chocolate(DP)
http://acm.hdu.edu.cn/showproblem.php?pid=4301 题意: 有一块n*2大小的巧克力,现在某人要将这巧克力分成k个部分,每个部分大小随意,问有多少种分法. 思 ...
- hdu 4301 dp
Divide Chocolate Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 5783 Divide the Sequence(数列划分)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 4548 美素数(打表)
HDU 4548 美素数(打表)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88159#problem/H 题目 ...
- [记录]Zabbix3.4配置监控Oracle12c的存活状态和表空间使用率
Zabbix3.4配置监控Oracle的存活状态和表空间使用率 1.安装zabbix3.4 agent: # rpm -ivh http://repo.zabbix.com/zabbix/3.4/rh ...
- hdu 4352 数位dp + 状态压缩
XHXJ's LIS Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- [转]查看处于被锁状态的表:v$locked_object dba_objects v$session all_objects v$sqlarea v$lock
oracle官网当一个用户发出select..for update的错作准备对返回的结果集进行修改时,如果结果集已经被另一个会话锁定,就是发生阻塞.需要等另一个会话结束之后才可继续执行.可以通过发出 ...
- C/C++用状态转移表联合函数指针数组实现状态机FSM
状态机在project中使用很的频繁,有例如以下常见的三种实现方法: 1. switch-case 实现.适合简单的状态机. 2. 二维状态表state-event实现.逻辑清晰.可是矩阵通常比較稀疏 ...
随机推荐
- Nodejs发送Post请求时出现socket hang up错误的解决办法
参考nodejs官网发送http post请求的方法,实现了一个模拟post提交的功能.实际使用时报socket hang up错误. 后来发现是请求头设置的问题,发送选项中需要加上headers字段 ...
- 注册dll失败
注册DLL的时候一出现错误: win8下: (右键弹出) 如果再不行, 64位系统下,把DLL移动到C:\Windows\SysWOW64下 更改路径
- Action的搭建及application、request、Session的运用 多种方法
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- Linux链接库一(动态库,静态库,库放在什么路径下)
http://www.cppblog.com/wolf/articles/74928.html http://www.cppblog.com/wolf/articles/77828.html http ...
- Smart Forms&ScriptFrom
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- CUBRID学习笔记 24 数据类型1
---恢复内容开始--- 一 数字类型 注意小数的四舍五入问题 1数字型 Type Bytes Mix Max Exact/approx. SHORTSMALLINT 2 -32,768 32,76 ...
- window.location.hash
我们知道JavaScript中很早就提供了window.history对象,利用history对象的forward().go().back()方法能够方便实现不同页面之间的前进.后退等这种导航功能.但 ...
- git学习笔记10-新开发的功能不想要了-强行删除分支
添加一个新功能时,你肯定不希望因为一些实验性质的代码,把主分支搞乱了,所以,每添加一个新功能,最好新建一个feature分支,在上面开发,完成后,合并,最后,删除该feature分支. 现在,你终于接 ...
- (一)mtg3000常见操作
一.查看MTG3000主控板IP地址: 重启设备后一直跑到shell,用户名和密码都输入admin,然后输入en进入命令行界面,输入sh int可查看设备IP等信息. 2.升级app.web程序
- Lua了解 & 为什么游戏开发用Lua
参考这篇文章 https://www.zhihu.com/question/21717567 看来就是网易风云为了让人写外挂不方便而采用的冷门语言.当然冷门的语言不代表不好用啦. Lua 虚拟机小,嵌 ...