[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. C++设计模式——观察者模式(转)

    前言 之前做了一个性能测试的项目,就是需要对现在的产品进行性能测试,获得测试数据,然后书写测试报告,并提出合理化的改善意见.项目很简单,我们获得了一系列性能测试数据,对于数据,我们需要在Excel中制 ...

  2. 函数select、poll

    函数select select函数: int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct ...

  3. javascript OOP(上)(八)

    一.OOP的概念和继承 1.OOP概念 面向对象程序设计(Object-oriented programming,OOP)是一种程序设计范型,同时也是一种程序开发的方法.对象指的是类的实例.它将对象作 ...

  4. NEST - 编写布尔查询

    Writing bool queries Version:5.x 英文原文地址:Writing bool queries 在使用查询 DSL 时,编写 bool 查询会很容易把代码变得冗长.举个栗子, ...

  5. NEST - 编写查询

    Writing queries Version:5.x 英文原文地址:Writing queries 将数据索引到了 Elasticsearch 之后,就可以准备搜索它们了.Elasticsearch ...

  6. 【Android】 textview 中超出屏幕宽度的字符 省略号显示

    当利用textview显示内容时,显示内容过多可能会折行或显示不全,那样效果很不好. 实现如下: <TextView android:layout_width="fill_parent ...

  7. ssh连接时提示THE AUTHENTICITY OF HOST XX CAN’T BE ESTABLISHED

    ssh链接云主机: ssh root@123.59.xx.xx 报错:THE AUTHENTICITY OF HOST XX CAN’T BE ESTABLISHED 解决办法: ssh -o Str ...

  8. glusterfs分布式复制扩容卷以及平衡卷

    随着数据量的增长,需要扩容满足使用.今天测试下glusterfs磁盘扩容的具体步骤 1.扩容 之前用的2台计算机的分布式复制卷.需要同时之两个服务器增加一块磁盘并格式化,挂载并扩容 热添加磁盘 ech ...

  9. 去掉select的原有样式

    1:设置select的边框为0px,背景设成透明(background: transparent;),这时候你会看到边框没有了,但是小三角还是在的.再在select外面加个div,固定死div的宽度, ...

  10. k8s教程

    k8s教程地址 安装https://github.com/gjmzj/kubeaszhttps://github.com/opsnull/follow-me-install-kubernetes-cl ...