(完全背包 大数)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看见加的背包专题我老去凑热闹,觉得太便宜我了.他们新加的搜索专题居然有密码. 都是兄弟院校嘛!何必那么小气. 回到正题,跟我写的上一篇关于求组成方案的背包思路基本一样,无非就是一个二维费 ...
随机推荐
- oracle合并版本
1) 添加字段,并自增 第一步:alter table TOWN add ID int 第二步:Update TOWN set id=rownum; Commit; 2) 更新表(另一张表) ...
- man ascii
Linux 2.6 - man page for ascii (linux section 7) - Unix & Linux Commands Linux 2.6 - man page fo ...
- ubuntu apt 安装
1. ./autogen.sh: libtoolize: not found sudo apt-get install aptitude sudo aptitude install libtool 2 ...
- PDF打水印加密
using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using S ...
- Java基础知识系列——目录操作
Java对目录操作的许多方法与上一篇文件操作的方法很多是一样的. java.io.File file = new File( "D:\1\2\3\4"); 1.递归创建目录 fil ...
- 微信企业号-JS-SDK图像接口
使用JS-SDK需要进行四步 主要是步骤二和步骤三,步骤二需要配置,步骤三具体使用相关接口,这里以使用图像接口为例 php页面代码主要用来完成步骤二,也就是配置接口 public function ...
- oracle win7下 卸载
1 右击“计算机”-->管理-->服务和应用程序-->服务,停掉所有Oracle相关的服务(以Oracle打头的,比如OracleDBConsoleorcl). 2 开始--> ...
- apktool+dex2jar+xjad反编译android程序
1 将MyAdroid.apk拷贝到E:\disapk 2 下载apktool1.5.2.tar.bz2 和 apktool-install-windows-r05-ibot.tar.bz2 并解压到 ...
- OA及权限系统
一直想找一款适合自己的权限管理后台,始终都没找到合适的,决定自己写一个 开发环境:vs2012 ,sql2008 语言:C# 前端:ligurui,jquery ORM框架:EF6.0 先来晒下我的数 ...
- Qt 程序访问 sqlite 权限错误
在Linux桌面上开发应用,想要拥有root权限,可是又需要弹窗申请.所以尽量避免这种情况发生. 另外:gksu,pkexec可以提供gui的root权限索取功能. 因为db文件是安装的时候放到etc ...