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实现.逻辑清晰.可是矩阵通常比較稀疏 ...
随机推荐
- JAVA排序--[选择排序]
package com.array; public class Sort_Select { /** * 项目名称:选择排序 ; * 项目要求:用JAVA对数组进行排序,并运用选择排序算法; * 作者: ...
- 折半查找&clock函数
#include <stdio.h>#include <time.h> #define CLOCKS_PER_SEC ((clock_t)1000) int binsearch ...
- MySQL子查询(SubQuery)
由比较运算符引发的子查询,若括号内的子查询结果为多个,要在括号前加上ANY/SOME/ALL 由[NOT]IN引发的子查询, =ANY与IN等效 !=ALL / <>ALL与N ...
- 《Linux内核设计的艺术》学习笔记(七)INT 0x15中断
参考资料: 1. <IBM-PC汇编语言程序设计> 2. http://blog.sina.com.cn/s/blog_5028978101008wk2.html 3. http://ww ...
- ACCESS 数据库使用配置调整解决方案
分享到 一键分享 QQ空间 新浪微博 百度搜藏 人人网 腾讯微博 百度相册 开心网 腾讯朋友 百度贴吧 豆瓣网 搜狐微博 百度新首页 QQ好友 和讯微博 更多... 百度分享 64位服务器无法使用ac ...
- iOS - OC RunTime 运行时
1.运行时的使用 向分类中添加属性 // 包含运行时头文件 #import <objc/runtime.h> /* void objc_setAssociatedObject(id obj ...
- DBCP、C3P0、Proxool 、 BoneCP开源连接池的比《转》
简介 使用评价 项目主页 DBCP DBCP是一个依赖Jakarta commons-pool对象池机制的数据库连接池.DBCP可以直接的在应用程序用使用 可以设置最大和最小连接,连接等待时 ...
- 十种JAVA排序算法实例
一.冒泡(Bubble)排序 复制代码 代码如下: void BubbleSortArray() { for(int i=1;i<n;i++) { for ...
- 基本分类方法——KNN(K近邻)算法
在这篇文章 http://www.cnblogs.com/charlesblc/p/6193867.html 讲SVM的过程中,提到了KNN算法.有点熟悉,上网一查,居然就是K近邻算法,机器学习的入门 ...
- iOS开发之 XCode6.0的iOS免证书真机测试方法(MAC及黑苹果均有效)
参考:http://mobile.51cto.com/iphone-455500.htm XCode6.0的iOS免证书真机测试方法(MAC及黑苹果均有效) 前提:设备已经越狱 目前在XCode上开发 ...