Skip to content

Instantly share code, notes, and snippets.

@lackofdream
Created March 30, 2015 10:33
Show Gist options
  • Save lackofdream/242772d285070e564361 to your computer and use it in GitHub Desktop.
Save lackofdream/242772d285070e564361 to your computer and use it in GitHub Desktop.
HDU1028
#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 main()
{
int res[150],tmp[150];
for (int i=0;i<150;i++)
{
res[i]=1;
tmp[i]=0;
}
for (int i=2;i<150;++i)
{
for (int j=0;j<150;++j)
{
for (int k=0;k+j<150;k+=i)
{
tmp[j+k]+=res[j];
}
}
for (int j=0;j<150;++j)
{
res[j]=tmp[j]; tmp[j]=0;
}
}
int n;
while(~sd(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