[CF543A]/[CF544C]Writing Code

题目大意:

有\(n\)种物品,每种物品分别要\(c_i\)的代价,每个物品有\(1\)的体积,每个物品可以选多个,代价不能超过\(b\),求正好填满大小为\(m\)的背包的方案数。

思路:

\(f[i][j]\)表示有\(i\)个物品,总代价为\(j\)的方案数。\(\mathcal O(n^3)\)DP即可。

源代码:

#include<cstdio>
#include<cctype>
inline int getint() {
register char ch;
while(!isdigit(ch=getchar()));
register int x=ch^'0';
while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
return x;
}
const int N=501,mod=1e9+7;
int f[N][N];
int main() {
const int n=getint(),m=getint(),b=getint();
f[0][0]=1;
for(register int i=1;i<=n;i++) {
const int x=getint();
for(register int j=1;j<=m;j++) {
for(register int k=x;k<=b;k++) {
(f[j][k]+=f[j-1][k-x])%=mod;
}
}
}
int ans=0;
for(register int i=0;i<=b;i++) {
(ans+=f[m][i])%=mod;
}
printf("%d\n",ans);
return 0;
}

[CF543A]/[CF544C]Writing Code的更多相关文章

  1. Codeforces Round #302 (Div. 2).C. Writing Code (dp)

    C. Writing Code time limit per test 3 seconds memory limit per test 256 megabytes input standard inp ...

  2. 完全背包 Codeforces Round #302 (Div. 2) C Writing Code

    题目传送门 /* 题意:n个程序员,每个人每行写a[i]个bug,现在写m行,最多出现b个bug,问可能的方案有几个 完全背包:dp[i][j][k] 表示i个人,j行,k个bug dp[0][0][ ...

  3. (完全背包)Writing Code -- Codeforce 544C

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=99951#problem/C  (zznu14) Writing Code  Writin ...

  4. Codeforces Round #302 (Div. 2) C. Writing Code 简单dp

    C. Writing Code Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/prob ...

  5. CF543A Writing Code

    题目描述 Programmers working on a large project have just received a task to write exactly m m m lines o ...

  6. CodeForces 543A - Writing Code DP 完全背包

    有n个程序,这n个程序运作产生m行代码,但是每个程序产生的BUG总和不能超过b, 给出每个程序产生的代码,每行会产生ai个BUG,问在总BUG不超过b的情况下, 我们有几种选择方法思路:看懂了题意之后 ...

  7. Code Forces 543A Writing Code

    题目描述 Programmers working on a large project have just received a task to write exactly mm lines of c ...

  8. A. Writing Code 完全背包

    http://codeforces.com/contest/543/problem/A 一开始这题用了多重背包做,结果有后效性. 就是如果6,这样拆分成 1 + 2 + 3的,那么能产生3的就有两种情 ...

  9. Codeforces 543A Writing Code

    http://codeforces.com/problemset/problem/543/A 题目大意:n个人,一共要写m行程序,每个程序员每行出现的bug数为ai,要求整个程序出现的bug数不超过b ...

随机推荐

  1. 编程语言,执行python程序,变量(命名规范)

    编程语言 分类: ​ 计算语言/汇编语言/高级语言 计算语言: ​ 站在计算机的角度,说计算机能听懂的语言,就是直接用二进制编程,直接操作硬件 优点是最底层,执行速度最快 缺点是最复杂,开发效率最低 ...

  2. 俺也会刷机啦--windows7下刷android

    刷机很多人都会,本文只为像我这种入门的朋友而写的. 风险提示: 1. SD卡数据极可能会丢失(我这次就全丢了). 2. 升级失败. (俺的)环境说明: windows7 专业版64位 cmd命令行工具 ...

  3. 步步为营-77-Ajax简介

    AJax:异步JavaScript和XML.Asynchronous JavaScript and XML 优点:无刷新 1 JavaScript下的Ajax 1.1 XMLHttpRequest对象 ...

  4. 该问题是需要导包!!!需要pom中添加依赖The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

    <!-- https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl --><depend ...

  5. 012-Python-paramiko和IO多路复用

    1.IO 多路复用 1.监听多个socket变化 2.socket服务端 IO多路复用+socket 来实现web服务器: a.服务端优先运行 b.浏览器:http://.......com 浏览器连 ...

  6. Github版本管理以及git使用

    1.git客户端编译安装 同步系统时间服务器 ntpdate cn.ntp.org.cn 安装依赖包: [root@baolin ~]# yum install epel-release -y [ro ...

  7. Zookeeper(一)CentOS7.5搭建Zookeeper3.4.12集群与命令行操作

    一. 分布式安装部署 1.0 下载地址 官网首页: https://zookeeper.apache.org/ 下载地址: http://mirror.bit.edu.cn/apache/zookee ...

  8. hdu2036

    题解: 求多边形面积 分成很多块三角形求就可以了 凹的也是支持的 代码: #include <bits/stdc++.h> using namespace std; #define rin ...

  9. BZOJ 4282(慎二的随机数列

    题解: 网上题解还没看 我的方法是用平衡树维护一个单调栈 由于N用了一定是赚的 所以它的作用是让f[i+1]=f[i]+1 这个是可以记录的 就跟noip蚯蚓那题一样 然后插入一个值的时候查询前面的最 ...

  10. 构建简单的json树形菜单

    json结构: var Menu = [{ tit:"一级菜单", submenu:[{ tit:"二级菜单", url:"", func: ...