NYOJ Cut the rope
来源:互联网 发布:网络舆情队伍建设 编辑:程序博客网 时间:2024/05/21 17:40
Cut the rope
时间限制:1000 ms | 内存限制:65535 KB
难度:4
- 描述
We have a rope whose length is L. We will cut the rope into two or more parts, the length of each part must be an integer, and no two parts have the same length.
Your task is to calculate there exists how many results after the cutting. We say two results are different if and only if there is at least one part, which we can find in one result but can not find in the other result- 输入
- There is an integer T (1 <= T <= 50000) in the first line, which indicates there are T test cases in total.
For each test case, there is only one integer L (1 <= L <= 50000) which has the same meaning as above. - 输出
- For each test case, you should output the correct answer of the above task in one line.
Because the answer may be very large, you should just output the remainder of it divided by 1000000 instead - 样例输入
3236
- 样例输出
013
上传者
动态规划,dp[i][j]表示i分解陈j个数的数量,
dp[i][j]=dp[i-j][j](不包含1)+dp[i-j][j-1](包含1);
AC代码:
# include <cstdio># include <cstring># include <cmath># include <cstdlib>using namespace std;const int mod=1000000;int dp[50010][320];int main(){int n, t, i, j, k, sum;memset(dp, 0, sizeof(dp));dp[3][2]=1;dp[4][2]=1;dp[5][2]=2;dp[6][2]=2;dp[6][3]=1;for(i=1; i<=50000; i++){dp[i][1]=1;}for(i=7; i<=50000; i++){for(j=2; j*(j+1)/2<=i; j++){dp[i][j]=(dp[i-j][j]+dp[i-j][j-1])%mod;}}scanf("%d", &t);for(i=1; i<=t; i++){scanf("%d", &n);sum=0;for(k=2; k*(k+1)/2<=n; k++){sum=(sum+dp[n][k])%mod;}printf("%d\n", sum);}return 0;}
0 0
- NYOJ Cut the rope
- cocos2d cut the rope
- hdu 4476 Cut the rope
- hdu 4476 Cut the rope
- HDU 4476 Cut the rope
- hdu 4476 Cut the rope
- NYOJ 651 Cut the rope(DP, 经典的整数划分问题)
- Cut The Rope正式登录pc
- html5在线网页游戏-Cut The Rope割绳子免费版
- cut the rope HTML 5版本背后的开发故事
- 《Cut The Rope》 HTML 5版背后的开发故事
- HDU-4476 Cut the rope (枚举、前缀和)
- 用 Box2D 来制作类似 Cut the Rope 游戏里的绳子
- 带你一起分析cut the rope(切绳子游戏)中绳子的制作方法
- hdu_4476_Cut the rope
- The Rope Bridge
- hdu 4344 Mark the Rope
- hdu 4344 Mark the Rope
- js 对象动态属性
- 理解Cookie和Session机制
- pcl里面的RoPs特征(Rotational Projection Statistics)
- jQuery on()方法
- [算法练习]实现itoa,atoi
- NYOJ Cut the rope
- 写博客,从现在开始
- UI调试神器 for ios:Reveal的使用与破解
- jqGrid 学习笔记整理——进阶篇(二)
- js 声明变量
- WebViewJavascriptBridge详细使用
- Swift高阶函数map,filter,reduce实践
- 首试GPU并行运算
- 常用正则表达式