[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. Java 9 中的 9 个新特性你知道吗

    摘要: Java 8 发布三年多之后,即将快到2017年7月下一个版本发布的日期了. 你可能已经听说过 Java 9 的模块系统,但是这个新版本还有许多其它的更新. 这里有九个令人兴奋的新功能将与 J ...

  2. MAC 调用GCC 提示xcrun: error: invalid active developer path

    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: ...

  3. 论文阅读笔记七:Structure Inference Network:Object Detection Using Scene-Level Context and Instance-Level Relationships(CVPR2018)

    结构推理网络:基于场景级与实例级目标检测 原文链接:https://arxiv.org/abs/1807.00119 代码链接:https://github.com/choasup/SIN Yong ...

  4. 步步为营-90-SEO(url重写+超链接技巧)

    目的:便于搜索引擎抓取 url重写:将带参数的url如:https://i.cnblogs.com/EditPosts.aspx?opt=1.修改为https://i.cnblogs.com/Edit ...

  5. JAVA 程序编译过程;编辑器,编译器和解释器

    最基本的软件工具包括,编辑器,编译器,解释器; 编译器:编译器就是将一种编程语言代码翻译成另一种语言的等效代码程序. 解释器:解释器将编译和执行交织在一起,即编译一部分代码后执行该部分代码,然后再编译 ...

  6. EXcel vba 获取批注信息

    Public Function pizhu(i As Range) pizhu = i.Cells.Comment.Text End Function EXcel VBA获取批注信息

  7. Html中,id、name、class、type的区别

    <input type="text" name="name" id="name" class="txt"> ...

  8. springboot的三种启动方式

    一:IDE 运行Application这个类的main方法 二:在springboot的应用的根目录下运行mvn spring-boot:run 三:使用mvn install 生成jar后运行 先到 ...

  9. JavaScript动态加载CSS和JS文件

    var dynamicLoading = { css: function(path){ if(!path || path.length === 0){ throw new Error('argumen ...

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

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