http://acm.nyist.net/JudgeOnline/problem.php?pid=651

描述
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
样例输入
3
2
3
6
样例输出
0
1
3

/*
1+2+3+4+...+k=(k+1)*k/2
N = 500000 (长度)
解得k = 316
dp[n][k]表示长度为n的线段分解成k段的方案数。
有2种情况:
1.有长度为1的:dp[n-k][k-1]
2.没有长度为1的;每段的长度减1后,与dp[n-k][k]的方案数相同 所以dp[n][k] = (dp[n-k][k-1]+dp[n-k][k])%Mod
观察dp,dp[n][k]需要的是左上角和上的信息。
所以递归基础是k=2和n=2的情况。(第一行第一列)
n=2, dp[2][i] = 0
k=2, dp[i][2] = (i-1)/2 ans[i]就是对dp[i][*]求和.
*/
#include <iostream>
#include <cstring>
using namespace std; #define N 50002
#define K 316
#define Mod 1000000
int m;
int n;
int dp[N][K];
int ans[N]; void pre()
{
ans[] = ans[] = ; for (int i = ; i < K; ++i)
dp[][i] = ;
for (int i = ; i < N; ++i)
dp[i][] = (i-)/; for (int i = ; i < N; ++i)
{
for (int j = ; j < K; ++j)
{
if (i-j >= )
dp[i][j] = (dp[i-j][j-] + dp[i-j][j])%Mod;
}
} for (int i = ; i < N; ++i)
for (int j = ; j < K; ++j)
ans[i] = (ans[i]+dp[i][j])%Mod;
} int main()
{
pre(); cin >> m; while (m--)
{
cin >> n; cout << ans[n] << endl;
}
}

Cut the rope的更多相关文章

  1. hdu 4476 Cut the rope (2-pointer && simulation)

    Problem - 4476 题意是,给出若干绳子,对同一根绳子只能切割一次,求出最多能获得多少长度相同的绳子. 代码中,s是最大切割长度,而当前切割长度为t/2. 代码如下: #include &l ...

  2. [Algo] 87. Max Product Of Cutting Rope

    Given a rope with positive integer-length n, how to cut the rope into m integer-length parts with le ...

  3. 推荐10款超级有趣的HTML5小游戏

    HTML5的发展速度比任何人的都想像都要更快.更加强大有效的和专业的解决方案已经被开发......甚至在游戏世界中!这里跟大家分享有10款超级趣味的HTML5游戏,希望大家能够喜欢! Kern Typ ...

  4. 8个超棒的HTML5网站设计欣赏

    我们听到了很多关于HTML5的新闻和技术动向,一个又一个的新的东西不停的出现,那么最近HTML5的技术应用又如何呢?HTML5又和CSS及其Javascript如何一起改变我们的网站设计和实现的呢? ...

  5. Codeforces Round #384 (Div. 2)D-Chloe and pleasant prizes

    D. Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabytes input ...

  6. Bungee Jumping[HDU1155]

    Bungee JumpingTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...

  7. coderforces #384 D Chloe and pleasant prizes(DP)

    Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  8. Codeforces Round #384 (Div. 2)A,B,C,D

    A. Vladik and flights time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  9. Codeforces Round #384 (Div. 2)D - Chloe and pleasant prizes 树形dp

    D - Chloe and pleasant prizes 链接 http://codeforces.com/contest/743/problem/D 题面 Generous sponsors of ...

随机推荐

  1. 深入理解Hadoop集群和网络【转】

    http://os.51cto.com/art/201211/364374.htm 本文将着重于讨论Hadoop集群的体系结构和方法,及它如何与网络和服务器基础设施的关系.最开始我们先学习一下Hado ...

  2. Ubuntu16.04安装Pytorch

    一.安装 1. 官方github:https://github.com/pytorch/pytorch Install optional dependencies //安装依赖项 On Linux e ...

  3. (如何理解gamma校准)GAMMA测试方法及分析

    http://wenku.baidu.com/link?url=Wz5oXJsFQ-TVe3qxm9Zd4pp207cQ4jmjuBnwmWAvD1ibgoI2U8y7KCFhaR9xWtu9cGLE ...

  4. Idea闪退问题-内存不能给太大

    Idea闪退问题-内存不能给太大 学习了:https://blog.csdn.net/qq_17776287/article/details/77529455 学习了:https://blog.csd ...

  5. JSON,字符串,MAP转换

    package com.tree.autotest.testcase.IAuditBillDetailService; import com.alibaba.fastjson.JSON;import ...

  6. CMake 设置Target输出目录和后缀名

    一. SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../bin) 上面的语句能设置可执行文件的输出目录 在Win + VS环境下,会自动在你所设置 ...

  7. 【CI】系列三.宿主机KVM配置及vdi与vmdk格式转换等

    前提:宿主机需要支持虚拟化,如果未打开,则需要重启机器,在bois中打开该项: Ubuntu 及 KVM 相关主要参考官方 https://wiki.ubuntu.com/kvm 另外也可参考该页面: ...

  8. mui 选项卡

    方法一:通过css 实现选项卡 <div id="slider" class="mui-slider"> <div id="slid ...

  9. PLSQL中scott账户登录不上,报错ORA-01017: invalid username/password; logon denied

    问题:PLSQL中scott账户登录不上,提示上述错误 解决方法: 1. cmd——>进入c目录; 2. 输入:sqlplus/nolog; 3. connect username/passwo ...

  10. C#导出Excel和相关打印设置

    Excel.Application myExcel = new Excel.Application();Excel.Workbook workbookData = myExcel.Applicatio ...