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实现.逻辑清晰.可是矩阵通常比較稀疏 ...
随机推荐
- 可是把ie67下面的bug改好了,其实很简单,ie67下面取出来的字符串是带有空格的,不知道为什么
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- jquery之event与originalEvent的关系、event事件对象用法浅析
在jquery中,最终传入事件处理程序的 event 其实已经被 jQuery 做过标准化处理, 其原有的事件对象则被保存于 event 对象的 originalEvent 属性之中, 每个 even ...
- CHECKBOX_CHECKED built-in in Oracle D2k Forms
CHECKBOX_CHECKED built-in in Oracle D2k Forms DescriptionA call to the CHECKBOX_CHECKED function ret ...
- 3.mybatis注解
在上篇2.mybatis入门实例(一) 连接数据库进行查询的基础上 1.添加Mapper接口:UserMapper接口,并使用mybatis的注解 import java.util.List; imp ...
- 关于Android构建
“IDE都是给小白程序员的,大牛级别的程序员一定是命令行控,终端控,你看大牛都是使用vim,emacs 就一切搞定” 这话说的虽然有些绝对,但是也不无道理,做开发这行要想效率高,自动化还真是缺少不了命 ...
- Redis基础知识之—— 缓存应用场景
转载原文:http://www.cnblogs.com/jinshengzhi/articles/5225718.html 一.MySql+Memcached架构的问题 Memcached采用客户端- ...
- C#操作Excel数据增删改查(转)
C#操作Excel数据增删改查. 首先创建ExcelDB.xlsx文件,并添加两张工作表. 工作表1: UserInfo表,字段:UserId.UserName.Age.Address.CreateT ...
- poj2540Hotter Colder(半平面交)
链接 根据距离可以列得直线方程,附上初始矩形的四个顶点,依次用直线切割. #include<iostream> #include <stdio.h> #include < ...
- 关于我们DOM的知识点
DOM的概念及子节点类型 前言 DOM的作用是将网页转为一个javascript对象,从而可以使用javascript对网页进行各种操作(比如增删内容).浏览器会根据DOM模型,将HTML文档解析 ...
- C++中的虚继承 & 重载隐藏覆盖的讨论
虚继承这个东西用的真不多.估计也就是面试的时候会用到吧.. 可以看这篇文章:<关于C++中的虚拟继承的一些总结> 虚拟基类是为解决多重继承而出现的. 如:类D继承自类B1.B2,而类B1. ...