Posted on 2008-03-14 20:52
superman 阅读(354)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1666 C++ 00:00.00 872K */
2 #include <iostream>
3
4 using namespace std;
5
6 int main()
7 {
8 int count[20][500] = {0};
9
10 for(int i = 0; i <= 17; i++)
11 count[i][0] = 1;
12
13 for(int i = 1; i <= 17; i++)
14 for(int j = 1; j <= 300; j++)
15 for(int k = 0; k * i * i <= j; k++)
16 if(count[i - 1][j - k * i * i])
17 count[i][j] += count[i - 1][j - k * i * i];
18 int n;
19 while((cin >> n) && n)
20 cout << count[17][n] << endl;
21
22 return 0;
23 }
24