hdu1284经典钱币兑换问题
生活随笔
收集整理的這篇文章主要介紹了
hdu1284经典钱币兑换问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
錢幣兌換問題。
題目?http://acm.hdu.edu.cn/showproblem.php?pid=1284
完全背包。
這種是求背包問題最多的組合方案
參考了一些資料 ??http://blog.csdn.net/wumuzi520/article/details/7021210
?
#include <stdio.h> #include <string.h> #include <algorithm> #include <iostream> using namespace std;int dp[32768]; int main() {int n;while(~scanf("%d",&n)){int i,j;memset(dp,0,sizeof(dp));dp[0]=1;for(i=1;i<=3;i++){for(j=i;j<=n;j++){if (j>=i)dp[j]=dp[j]+dp[j-i];}}cout<<dp[n]<<endl;}return 0; }?
?
轉載于:https://www.cnblogs.com/riasky/p/3431134.html
總結
以上是生活随笔為你收集整理的hdu1284经典钱币兑换问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 141.Linked List Cycl
- 下一篇: 面试官:什么是JDK什么是JRE?服务器