hdu1398

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long c1[301], c2[301]; 
void init() {
    for (int i = 0; i <= 300; i++) {
        c1[i] = 1;
        c2[i] = 0;
    }
    for (int i = 2; i <= 17; i++) {
        for (int j = 0; j <= 300; j++) {
            for (int k = 0; j+k <= 300; k+=i*i) {
                c2[j+k] += c1[j];
            }
        }
        for (int j = 0; j <= 300; j++) {
            c1[j] = c2[j];
            c2[j] = 0;
        }
    }
}
int main() {
  int n;
  init();
  while (scanf("%d", &n), n) {
      printf("%lld\n", c1[n]);
    }
}

 

posted @ 2017-11-11 14:25  白丁一枚  阅读(114)  评论(0编辑  收藏  举报