标签:blog io os sp for 2014 log as ios
题目:给你五个面值的货币1,5,10,25,50,问表示N有多少种不同方法。
分析:dp,多重背包。整数拆分用背包。
说明:打表计算,查询输出。
#include <iostream> #include <cstdlib> using namespace std; int F[7490] = {0}; int c[5] = {1,5,10,25,50}; int main() { F[0] = 1; for (int j = 0 ; j < 5 ; ++ j) for (int i = c[j] ; i < 7490 ; ++ i) F[i] += F[i-c[j]]; int n; while (cin >> n) cout << F[n] << endl; return 0; }
标签:blog io os sp for 2014 log as ios
原文地址:http://blog.csdn.net/mobius_strip/article/details/41909227