题目链接:

  Lightoj  1231 - Coin Change (I)

题目描述:

  就是有n种硬币,每种硬币有两个属性(价值,数目)。问用给定的硬币组成K面值,有多少种方案?

解题思路:

  赤果果的多重背包,简单搞一下就好了。席八!烦烦烦。今天绝对是出门刷提前没看黄历,刚开始套了一个多重背包板子,蓝而跑出来的答案并不对,改来改去就错在细节的地方。

 #include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; typedef long long LL;
const int mod = ;
const int maxn = ;
int dp[][maxn], a[], c[]; int main ()
{
int T;
scanf ("%d", &T);
for (int t=; t<=T; t++)
{
int n, k;
scanf ("%d %d", &n, &k);
memset (dp, , sizeof(dp));
dp[][] = ; for (int i=; i<=n; i++)
scanf ("%d", &a[i]);
for (int i=; i<=n; i++)
scanf ("%d", &c[i]); for (int i=; i<=n; i++)
for (int j=; j<=c[i]; j++)
for (int x=k; x>=a[i]*j; x--)
{
dp[i][x] = (dp[i][x] + dp[i-][x-a[i]*j]) % mod;
} printf ("Case %d: %d\n", t, dp[n][k]);
}
return ;
}

Lightoj 1231 - Coin Change (I) (裸裸的多重背包)的更多相关文章

  1. LightOJ - 1231 - Coin Change (I)

    先上题目: 1231 - Coin Change (I)   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit:  ...

  2. LightOJ - 1232 - Coin Change (II)

    先上题目: 1232 - Coin Change (II)   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: ...

  3. LightOJ 1235 - Coin Change (IV) (折半枚举)

    题目链接: http://www.lightoj.com/volume_showproblem.php?problem=1235 题目描述: 给出n个硬币,每种硬币最多使用两次,问能否组成K面值? 解 ...

  4. Lightoj 1235 - Coin Change (IV) 【二分】

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1235 题意: 有N个硬币(N<=18).问是否能在每一个硬币使用不超过两 ...

  5. C - Coin Change (III)(多重背包 二进制优化)

    C - Coin Change (III) Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu ...

  6. [LeetCode] Coin Change 硬币找零

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  7. HDOJ 2069 Coin Change(母函数)

    Coin Change Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  8. HDU 2069 Coin Change

    Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...

  9. UVA 674 Coin Change(dp)

    UVA 674  Coin Change  解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/ ...

随机推荐

  1. Python开发【2.3 模块】

    1.模块导入 import 模块名 from 模块名 import 函数/类/变量 2.模块路径 import sys sys.path 3.模块重新导入 Python3若想在同一次会话中再次运行文件 ...

  2. 距特征之k阶距概念

    k阶原点距和k阶中心距各是说明什么数字特征 http://www.cnblogs.com/emanlee/archive/2011/04/25/2028628.html 二阶中心距,也叫作方差,它告诉 ...

  3. 诺基亚(Microsoft Devices Group)2014暑期实习生笔试题知识点

    总结一下Microsoft Devices Group的软件类笔试题,全部笔试题分两份试卷,逻辑题一份和软件測试题一份,仅仅总结技术题喽~题目全英文,仅仅包括选择题和填空题.选择题居多.分单选和多选. ...

  4. hihocode #1388 : Periodic Signal NTT

    #1388 : Periodic Signal   描述 Profess X is an expert in signal processing. He has a device which can ...

  5. CentOS笔记-其他杂记

    1.忘记密码时,可以用single模式来修改密码,为了安全,可以禁用single模式,参考网址如下 Centos服务器禁止单用户模式(single)来增强系统安全 2.远程登录:ssh root@xx ...

  6. Docker and Go: why did we decide to write Docker in Go?

    Docker and Go: why did we decide to write Docker in Go? | Hacker News https://news.ycombinator.com/i ...

  7. 浏览器上的Qt Quick

    你想不想在浏览器上运行你的Qt Quick程序呢?在Qt 5.12之前,唯一的方法是使用Qt WebGL Streaming技术把界面镜像到浏览器上.但该方法有不少缺陷,下文会说.前不久随着Qt 5. ...

  8. 20170223-问题001,增强中的E消息 显示为 S模式消息,

     MM01 的屏幕增强,里面写的      MESSAGE e056(z1) WITH '供应链计划(SCP) 储备物料与当期物料不能同时选择.'.可是现实出来是S 消息模式,这是为什么?系统转换了吗 ...

  9. mysql_proxy

    mysql_proxy中间件实现:读写分离.负载均衡. mysql_proxy中间件实现:读写分离.负载均衡. 负载均衡:给多台数据库,看能不能均匀的分给不同的数据库. 客户端连的是proxy,此时的 ...

  10. PHP的date 函数

    <!DOCTYPE html> <html> <body> <?php echo "今天是 " . date("Y/m/d&qu ...