题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4651
题意:给你一个数n,让你输出将n拆分的方案数。
题解:公式题,不解释,当模版记住就行

1 #include <cstdio> 2 #include <cstring> 3 #define LL long long 4 const LL mod=1000000007; 5 LL p[100010]; 6 void init(){ 7 p[0]=p[1]=1,p[2]=2,p[3]=3; 8 for(int i=4; i<=100000;i++){ 9 int fg=1;p[i]=0; 10 for(int j=1;; ++j){ 11 int a=(j*j*3+j)/2,b=(j*j*3-j)/2; 12 if(b>i&&a>i)break; 13 if(a<=i)p[i]=(p[i]+p[i-a]*fg+mod)%mod; 14 if(b<=i)p[i]=(p[i]+p[i-b]*fg+mod)%mod; 15 fg=(-1)*fg; 16 } 17 } 18 } 19 int main(){ 20 init(); 21 int t,n; 22 scanf("%d",&t); 23 while(t--)scanf("%d",&n),printf("%I64d ",p[n]); 24 return 0; 25 }