传送门:Project Euler 76
Description
It is possible to write five as a sum in exactly six different ways:
4 + 1
3 + 2
3 + 1 + 1
2 + 2 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1
How many different ways can one hundred be written as a sum of at least two positive integers?
Solution
不解释,本蒟蒻又被完全背包虐了。
Code
#include<iostream>
using namespace std;
int f[5000];
int main()
{
int n;
f[0]=1;
cin>>n;
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
{
f[j]+=f[j-i];
}
cout<<f[n]-1;
return 0;
}