#include #include using namespace std; int main(void) { ifstream cin("coins.txt"); // pre-compute the solutions int T[300]; for(int i = 0; i < 300; i++) T[i] = 0; T[0] = 1; for(int j = 17; j >= 1; j--) { for(int i = j * j; i < 300; i++) T[i] += T[i - j * j]; } // main loop :-) int n; while(cin >> n) { if(n == 0) break; cout << T[n] << endl; } return 0; }