CF 189A Cut Ribbon
#include<bits/stdc++.h>
using namespace std;
const int maxn = 4000 + 131;
int n, a, b, c;
int Dp[maxn]; int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> a >> b >> c;
memset(Dp,0,sizeof(Dp));
Dp[a] = Dp[b] = Dp[c] = 1;
for(int i = 0; i <= n; ++i)
{
/// 前一种状态必须是被填过的
if(i >= a && Dp[i-a]) Dp[i] = max(Dp[i], Dp[i-a]+1);
if(i >= b && Dp[i-b]) Dp[i] = max(Dp[i], Dp[i-b]+1);
if(i >= c && Dp[i-c]) Dp[i] = max(Dp[i], Dp[i-c]+1);
}
cout << Dp[n] << endl;
}
CF 189A Cut Ribbon的更多相关文章
- 【CF 189A Cut Ribbon】dp
题目链接:http://codeforces.com/problemset/problem/189/A 题意:一个长度为n的纸带,允许切割若干次,每次切下的长度只能是{a, b, c}之一.问最多能切 ...
- Codeforces 189A. Cut Ribbon
题目链接:http://codeforces.com/problemset/problem/189/A 题意: 给你一个长度为 N 的布条, 再给你三个长度 a, b , c.你可以用剪刀去剪这些布条 ...
- Codeforces Round #119 (Div. 2) Cut Ribbon(DP)
Cut Ribbon time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #119 (Div. 2)A. Cut Ribbon
A. Cut Ribbon time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces 189A:Cut Ribbon(完全背包,DP)
time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : ...
- Cut Ribbon
Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the follo ...
- [CF189A]Cut Ribbon(完全背包,DP)
题目链接:http://codeforces.com/problemset/problem/189/A 题意:给你长为n的绳子,每次只允许切a,b,c三种长度的段,问最多能切多少段.注意每一段都得是a ...
- Codeforces Round #119 (Div. 2)
A. Cut Ribbon \(f(i)\)表示长为\(i\)的布条最多可以剪几段. B. Counting Rhombi \(O(wh)\)枚举中心计算 C. Permutations 将序列一映射 ...
- DP擎天
DP! 黄题: 洛谷P2101 命运石之门的选择 假装是DP(分治 + ST表) CF 982C Cut 'em all! 树形贪心 洛谷P1020 导弹拦截 单调队列水题 绿题: 洛谷P1594 护 ...
随机推荐
- Java SSM框架之MyBatis3(十)MyBatis批量插入数据(MySql)
插入成功后返回自增主键 <insert id="insertRole" parameterType="role" useGeneratedKeys=&qu ...
- JS处理数据四舍五入
一,使用Math.toFixed toFixed() 方法可把 Number 四舍五入为指定小数位数的数字. 语法NumberObject.toFixed(num) 但是网友说toFixed bug比 ...
- Java8新特性_stream API 练习
交易员类 public class Trader { private String name; private String city; public Trader() { } public Trad ...
- 15.scrapy模拟登陆案例
1.案例一 a.创建项目 scrapy startproject renren_login 进入项目路径 scrapy genspider renren "renren.com" ...
- 堆栈Stack介绍
堆栈(Stack)代表了一个后进先出的对象集合.当您需要对各项进行后进先出的访问时,则使用堆栈.当您在列表中添加一项,称为推入元素,当您从列表中移除一项时,称为弹出元素. Stack 类的方法和属性 ...
- mysql插入记录INSERT与多表更新
1.第一种:INSERT [INTO] tbl_name[ (col_name, ... ) ] {VALUES | VALUE}({expr |default}, ... ), (...), .. ...
- ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory
ubuntu16.04安装cuda8.0,tensorflow-gpu版本后,运行时报错: ImportError: libcudnn.so.5: cannot open shared object ...
- 第25月第3天 Mxshop项目记录01
1.项目 https://github.com/mtianyan/VueDjangoFrameWorkShop virtualenv命令 virtualenv . virtualenv -p /ana ...
- windows上git安装
Git的官方网站:http://git-scm.com 1.下载:http://msysgit.github.com/ 2.安装 3.配置 用户名.邮箱 这个很重要将来项目提交的账号 $ git ...
- Django REST framework 第四章 Authentication
到目前为止,撰写的API没有任何限制关于谁能更新.删除snippet. 我们更想要一些高级行为来确保: 1.代码段总是跟创建者有关联 2.只要认证通过的用户才能创建 3.只有创建者有权限更新或者删除 ...