UVA 357 Let Me Count The Ways
来源:互联网 发布:表白视频制作软件 编辑:程序博客网 时间:2024/05/16 23:51
背包变形。
#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <string>using namespace std;typedef unsigned long long ULL;const int MAXN = 30010;const int INF = 0x3f3f3f3f;ULL f[30010];int n, C;int V[] = {0, 50, 25, 10, 5, 1};void init(){memset(f, 0, sizeof(f));f[0] = 1;n = 5;}ULL sum(ULL a, ULL b){return a+b;}void dp(){for(int i = 1; i <= n; i++){for(int v = V[i]; v <= C; v++){f[v] = sum(f[v], f[v-V[i]]);}}if(f[C] > 1){printf("There are %llu ways to produce %d cents change.\n", f[C], C);}else printf("There is only 1 way to produce %d cents change.\n", C);}void solve(){init();dp();}int main(){while(~scanf("%d", &C)){solve();}return 0;}
- uva 357 Let Me Count The Ways
- uva 357 - Let Me Count The Ways
- UVA 357 Let Me Count The Ways
- UVA 357 Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- uva 357 let me count the ways
- UVa 357 - Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- UVA-357-Let Me Count The Ways
- UVA 357 Let Me Count The Ways
- UVa:357 Let Me Count The Ways
- UVa 357: Let Me Count The Ways
- UVA - 357 Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- uva 357 Let Me Count The Ways
- uva 357 - Let Me Count The Ways
- uva 357 Let Me Count The Ways
- VB.NET多线程Socket实现简单HTTP服务
- 找到字符串中最长单词
- Java-hive【未完成】
- 如何写DLL文件及调用DLL文件
- 我想成为一个程序员
- UVA 357 Let Me Count The Ways
- UVA 10066 The Twin Towers
- 做最好的自己:这十件事请放手
- 编程日记08
- ajax的缓存问题分析和解决方法
- mount 硬盘到挂载点
- CFileDialog选择多个文件
- php类
- Caching Bitmaps 缓存Bitmap