Square Coins
#include<stdio.h> #include<string.h> #include<stdlib.h> int c1[300],c2[300],N=290; void fun( ) { int i,j,k; for(i=0;i<=N;i++) { c1[i]=1; c2[i]=0; } for(i=2;i*i<=N;i++) { for(j=0;j<=N;j++) for(k=0;k+j<=N;k+=i*i) c2[j+k]+=c1[j]; for(j=0;j<=N;j++) { c1[j]=c2[j]; c2[j]=0; } } } int main( ) { fun(); int t; while(scanf("%d",&t),t) printf("%d\n",c1[t]); return 0; }
posted on 2011-05-12 08:50 more think, more gains 阅读(161) 评论(0) 编辑 收藏 举报