HDU 1028 —— Ignatius and the Princess III

来源:互联网 发布:mac装软件 编辑:程序博客网 时间:2024/06/14 19:31

原题:http://acm.hdu.edu.cn/showproblem.php?pid=1028


#include<iostream>using namespace std;const int maxn = 250;int arr[maxn], tmp[maxn];int n;int main(){    while(cin>>n){        for(int i = 0;i<=n;i++){            arr[i] = 1;            tmp[i] = 0;        }        for(int i = 2;i<=n;i++){            for(int j = 0;j<=n;j++){                for(int k = 0;k+j<=n;k+=i)                    tmp[j+k] += arr[j];            }            for(int j = 0;j<=n;j++){                arr[j] = tmp[j];                tmp[j] = 0;            }        }        cout<<arr[n]<<endl;    }    return 0;}


0 0
原创粉丝点击