MagicScaring

HDU1398

Dec 27th, 2017
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4. #define M 300
  5. int c1[M+1],c2[M+1];
  6. void solve()
  7. {
  8.     int i,j,k;
  9.     for(i=0;i<=M;++i)
  10.         c1[i]=1;
  11.     for(i=2;i<=17;++i){
  12.         for(j=0;j<=M;++j)
  13.     {
  14.         for(k=0;k+j<=M;k+=i*i)
  15.             c2[k+j]+=c1[j];
  16.     }
  17.     for(j=0;j<=M;++j)
  18.     {
  19.         c1[j]=c2[j];
  20.         c2[j]=0;
  21.     }
  22.     }
  23. }
  24. int main()
  25. {
  26.     solve();
  27.     int n;
  28.     while(scanf("%d",&n),n)
  29.   //  for(int i=1;i<=300;++i)
  30.     printf("%d\n",c1[n]);
  31.   //  cout << "Hello world!" << endl;
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment