(完全背包 大数)Dollar Dayz (POJ 3181)
Description
- 1 @ US$3 + 1 @ US$2
1 @ US$3 + 2 @ US$1
1 @ US$2 + 3 @ US$1
2 @ US$2 + 1 @ US$1
5 @ US$1
Write a program than will compute the number of ways FJ can spend N dollars (1 <= N <= 1000) at The Cow Store for tools on sale with a cost of $1..$K (1 <= K <= 100).
Input
Output
Sample Input
- 5 3
Sample Output
- 5
- #include <iostream>
- #include <queue>
- #include <cmath>
- #include <cstdio>
- #include <cstring>
- #include <cstdlib>
- #include <stack>
- #include <vector>
- #include <algorithm>
- using namespace std;
- #define N 2100
- #define met(a,b) (memset(a,b,sizeof(a)))
- typedef long long LL;
- LL dp[N][];
- int main()
- {
- int n, m;
- while(scanf("%d%d", &n, &m)!=EOF)
- {
- int i, j;
- met(dp, );
- dp[][] = ;
- for(i=; i<=m; i++)
- for(j=i; j<=n; j++)
- {
- dp[j][] += dp[j-i][];
- dp[j][] += dp[j-i][];
- dp[j][] += dp[j][]/;
- dp[j][] %= ;
- }
- if(dp[n][]==)
- printf("%I64d\n", dp[n][]);
- else
- {
- printf("%I64d%015I64d\n", dp[n][], dp[n][]);
- }
- }
- return ;
- }
参考http://www.cnblogs.com/kuangbin/archive/2012/09/20/2695165.html
(完全背包 大数)Dollar Dayz (POJ 3181)的更多相关文章
- Dollar Dayz POJ - 3181
解法 完全背包+大数...不想写大数了放个python得了 代码 dp=[0 for i in range(2000)] n,k=map(int,input().split()) num=[i for ...
- DP:Dollar Dayz(POJ 3181)
一道高精度DP 题目大意,换工具,有m块钱,有k种价值的物品,(1...k),求一共有多少种换法 这一题就是完全背包,现在这种完全背包对我来说就是水题了, 状态转移方程闭着眼睛写dp[j]+=dp[j ...
- POJ 3181 Dollar Dayz(全然背包+简单高精度加法)
POJ 3181 Dollar Dayz(全然背包+简单高精度加法) id=3181">http://poj.org/problem?id=3181 题意: 给你K种硬币,每种硬币各自 ...
- POJ 3181 Dollar Dayz && Uva 147 Dollars(完全背包)
首先是 Uva 147:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_p ...
- POJ 3181 Dollar Dayz 【完全背包】
题意: 给出两个数,n,m,问m以内的整数有多少种组成n的方法完全背包+大数划分 思路: dp[i][j] := 用i种价格配出金额j的方案数. 那么dp[i][0] = 1,使用任何价格配出金额0的 ...
- poj 3181 Dollar Dayz(完全背包)
Dollar Dayz Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5419 Accepted: 2054 Descr ...
- Dollar Dayz(大数母函数,高低位存取)
Dollar Dayz Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5655 Accepted: 2125 Descr ...
- poj3181 背包+大数
http://poj.org/problem?id=3181 Dollar Dayz Time Limit: 1000MS Memory Limit: 65536K Total Submissio ...
- poj 3181 Dollar Dayz(求组成方案的背包+大数)
可能nyist看见加的背包专题我老去凑热闹,觉得太便宜我了.他们新加的搜索专题居然有密码. 都是兄弟院校嘛!何必那么小气. 回到正题,跟我写的上一篇关于求组成方案的背包思路基本一样,无非就是一个二维费 ...
随机推荐
- sql查询当天,一周,一个月数据的语句
--查询当天: select * from info where DateDiff(dd,datetime,getdate())=0 --查询24小时内的: select * from info w ...
- Postgresql死锁处理
今天遇到Postgresql的一个问题,部分表记录的update一直无效报错,初步判断为锁表,赶紧进行解决. 1. 查询死锁进程列表 select * from pg_stat_activity wh ...
- extern关键字
1.extern "C" void func(){...} extern可以置于变量或者函数前,以标示变量或者函数的定义在别的文件中,提示编译器遇到此变量和函数时在其他模块中寻找其 ...
- iOS常用网络库之AFNetWorking
简介 `AFNetworking`是iOS开发网络API中最常用的第三方库,`github`中的`star`数充分说明了它在iOS开发中第三方库中的江湖地位 github地址:[AFNe ...
- div里面的id与for
<input class="select" type="checkbox" value="1" id="checkboxjc ...
- python函数动态参数详解
Python的动态参数: 1,参数前一个"*":在函数中会把传的参数转成一个元组. def func (*args): print(args) func(123,1,2,'a') ...
- EF MYSQL 不能选择实体框架版本
web.config文件里面加如下配置,然后编译 <provider invariantName="MySql.Data.MySqlClient" type="My ...
- MVC 过滤器 构建会员是否登录
使用环境:在后台管理或者前台有会员中心的情况下使用 使用方式:这是一个用户中心的控制器 我给用户中心主页增加一个特性 [AccountFilter]这是一个过滤器的名字 public class Ac ...
- 前端自动构建工具@gulp入门
gulp是一个自动化的前端工具.它可以利用自身的插件来实现一些功能,如sass.less编译:浏览器自动刷新,文件压缩.重命名.代码校验(个人使用sublime的插件进行校验)等功能.当然这些功能也可 ...
- 升级到VS2012,reportViewer无法使用
最近公司的开发环境升级到VS2012,为了电脑能够快点,我重装系统,只装VS2012没有装VS2010.这个时候问题来了,原本用VS2010开发的项目用VS2012编译能通过,运行时包下图错: 为了解 ...