标签:int ane bsp bottom 硬币 input cep can tor
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9699 Accepted Submission(s): 5898
完全背包。只是统计方案数。
dp[i]代表 组成i的方法数。那么 dp[i]可由dp[i-1],dp[i-2],dp[i-3]转移过来...
/* *********************************************** Author :guanjun Created Time :2016/12/6 11:36:45 File Name :hdu1284.cpp ************************************************ */ #include <bits/stdc++.h> #define ull unsigned long long #define ll long long #define mod 90001 #define INF 0x3f3f3f3f #define maxn 10010 #define cle(a) memset(a,0,sizeof(a)) const ull inf = 1LL << 61; const double eps=1e-5; using namespace std; priority_queue<int,vector<int>,greater<int> >pq; struct Node{ int x,y; }; struct cmp{ bool operator()(Node a,Node b){ if(a.x==b.x) return a.y> b.y; return a.x>b.x; } }; bool cmp(int a,int b){ return a>b; } int dp[40000]; int main() { #ifndef ONLINE_JUDGE //freopen("in.txt","r",stdin); #endif //freopen("out.txt","w",stdout); int n; dp[0]=1; for(int i=1;i<=3;i++){ for(int j=i;j<=36000;j++) dp[j]+=dp[j-i]; } while(~scanf("%d",&n)){ printf("%d\n",dp[n]); } return 0; }
标签:int ane bsp bottom 硬币 input cep can tor
原文地址:http://www.cnblogs.com/pk28/p/6137002.html