Created
March 30, 2015 10:49
-
-
Save lackofdream/5771d55d47b5b7436b0a to your computer and use it in GitHub Desktop.
HDU1398
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <iostream> | |
#include <queue> | |
#include <stack> | |
#include <algorithm> | |
#include <fstream> | |
#include <cstring> | |
#include <unordered_set> | |
#include <map> | |
#define sd(x) scanf("%d",&x) | |
#define sdd(x,y) scanf("%d%d",&x,&y) | |
using namespace std; | |
int allcoins[]={0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289}; | |
const int MAXN = 320; | |
int main() | |
{ | |
int res[MAXN],tmp[MAXN]; | |
for (int i=0;i<MAXN;i++) | |
{ | |
res[i]=1; | |
tmp[i]=0; | |
} | |
for (int i=2;i<18;++i) | |
{ | |
for (int j=0;j<MAXN;++j) | |
{ | |
for (int k=0;k+j<MAXN;k+=allcoins[i]) | |
{ | |
tmp[j+k]+=res[j]; | |
} | |
} | |
for (int j=0;j<MAXN;++j) | |
{ | |
res[j]=tmp[j]; tmp[j]=0; | |
} | |
} | |
int n; | |
while(~sd(n) && n) | |
{ | |
printf("%d\n",res[n]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment