/*
The number of coin types is 1 ^ 2 ^ 2 ^ 2, 4 ^ 2... 17 ^ 2. Input n to find the number of combinations that can be combined into n;
Similar to hdu1028, but only the original 1, 2, 3, 4 ,...... Changed to 1 ^ 2, 2 ^ 2, 3 ^ 2, 4 ^ 2 ......,
Question Link
Http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 1398
*/
# Include <iostream> # include <cstring> using namespace std; int a [305], B [305]; int main () {int n; int c [18]; for (int I = 0; I <= 17; I ++) {c [I] = I * I;} while (cin> n & n! = 0) {for (int I = 0; I <= n; I ++) {a [I] = 1; B [I] = 0 ;} for (int I = 2; I <= 17; I ++) {for (int j = 0; j <= n; j ++) // enumerated known range (result of all previous items) for (int k = 0; k + j <= n; k + = c [I]) // new enumerated range (next) {B [j + k] + = a [j];} for (int j = 0; j <= n; j ++) // reset {a [j] = B [j]; B [j] = 0 ;}} cout <a [n] <endl ;}}