3 3 4 5
1 1 2
<span style="font-size:18px;">#include<stdio.h> #include<string.h> int c1[10010],c2[10010]; int prime[200]={2,3,5}; void f() { int i,j,k=3; for(i=7;i<=200;i++) { int flag=1; for(j=2;j*j<=i;j++) if(i%j==0) { flag=0; break; } if(flag) prime[k++]=i; } } int main() { int t,n,i,j,k; f(); scanf("%d",&t); while(t--) { memset(c2,0,sizeof(c2)); memset(c1,0,sizeof(c1)); scanf("%d",&n); for(i=0;i<=n;i+=prime[0]) c1[i]=1; for(i=1;prime[i]<=n;i++) { for(j=0;j<=n;j++) for(k=0;k+j<=n;k+=prime[i]) c2[j+k]+=c1[j]; for(j=0;j<=n;j++) c1[j]=c2[j],c2[j]=0; } printf("%d\n",c1[n]); } return 0; }</span>
杭电 2189(母函数 素数 打表),布布扣,bubuko.com
原文地址:http://blog.csdn.net/ice_alone/article/details/38491203