hdu-4615 Partition
来源:互联网 发布:绘制平面图的软件 编辑:程序博客网 时间:2024/05/21 10:41
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=4651
题目大意就是整数拆分
数据特别大,不能用以前的递归
所以。。。 不能百度 只能谷歌http://en.wikipedia.org/wiki/Partition_%28number_theory%29
然后在里面找一个公式
Leonhard Euler'spentagonal number theorem implies the identity
where the summation is over all nonzero integers k (positive and negative) andp(m) is taken to be 0 if m < 0.
但这个公式不完全,然后自己推理,再加小小的DP,就有代码了,
代码如下:
#include <iostream>#include <cstdio>#define MAX 100000+10#define MOD 1000000007using namespace std;int f[MAX];void init(){ for(int i=3; i<=100000; i++) { f[i]=0; for(int j=1; j*(3*j-1)/2 <=i; j++) { if(j%2==0) { f[i]=(f[i]-f[i-j*(3*j-1)/2]+MOD)%MOD; if((i-j*(3*j-1)/2-j)>=0) f[i]=(f[i]-f[i-j*(3*j-1)/2-j]+MOD)%MOD; } else { f[i]= (f[i]+f[i-j*(3*j-1)/2])%MOD; if((i-j*(3*j-1)/2-j)>=0) f[i]=(f[i]+f[i-j*(3*j-1)/2-j])%MOD; } } }}int main(){ int T; f[0]=1;f[1]=1;f[2]=2; init(); scanf("%d",&T); while(T--) { int n; scanf("%d",&n); printf("%d\n",f[n]); }}
- hdu-4615 Partition
- hdu - 4602 《Partition》
- HDU 4602 Partition
- HDU 4062 Partition
- HDU 4602 Partition
- hdu-4602-Partition
- hdu 4602 Partition
- HDU 4602 Partition
- HDU 4651 Partition
- hdu 4602 Partition
- HDU 4658 Integer Partition
- hdu(4602) Partition
- hdu 4602 Partition
- HDU 4602 Partition
- hdu 4658Integer Partition
- hdu 4651Partition
- hdu 4602 Partition
- HDU 4602 Partition
- struts1和struts2安全性比较
- README.TXT
- C可变参数函数 实现
- 如何使图片在DIV 中水平垂直居中
- LVS环境搭建及图形化管理(Pacemaker管理+heartbeat心跳+ipvs(DR)+ldirector健康检查及转发)
- hdu-4615 Partition
- 模式识别绪论1:基本概念
- sqlplus命令行工具格式化命令
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- c# 线程池中的所有线程结束之后执行的事件
- 在treeWidget中加入控件
- ORACLE DATABASE LINK
- 二叉树的探索 poj 2255
- poj 1321 棋盘问题 深搜+剪枝