mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1398_cnblogs.cpp
From http://www.cnblogs.com/qiufeihai/archive/2012/09/11/2680840.html
This commit is contained in:
parent
1701104c48
commit
94ffd5d482
32
HDOJ/1398_cnblogs.cpp
Normal file
32
HDOJ/1398_cnblogs.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
|
||||
const int M = 300 + 10;
|
||||
|
||||
int dp[M];
|
||||
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
while (~scanf("%d", &n), n)
|
||||
{
|
||||
|
||||
memset(dp, 0, sizeof(dp));
|
||||
dp[0] = 1;
|
||||
|
||||
int max = (int)sqrt(n * 1.0);
|
||||
for (int i = 1; i <= max; i++)
|
||||
{
|
||||
for (int j = i * i; j <= n; j++)
|
||||
{
|
||||
dp[j] += dp[j - i * i];
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d\n", dp[n]);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user