#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的更多相关文章

  1. 【CF 189A Cut Ribbon】dp

    题目链接:http://codeforces.com/problemset/problem/189/A 题意:一个长度为n的纸带,允许切割若干次,每次切下的长度只能是{a, b, c}之一.问最多能切 ...

  2. Codeforces 189A. Cut Ribbon

    题目链接:http://codeforces.com/problemset/problem/189/A 题意: 给你一个长度为 N 的布条, 再给你三个长度 a, b , c.你可以用剪刀去剪这些布条 ...

  3. 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 ...

  4. 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 ...

  5. Codeforces 189A:Cut Ribbon(完全背包,DP)

    time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : ...

  6. Cut Ribbon

    Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the follo ...

  7. [CF189A]Cut Ribbon(完全背包,DP)

    题目链接:http://codeforces.com/problemset/problem/189/A 题意:给你长为n的绳子,每次只允许切a,b,c三种长度的段,问最多能切多少段.注意每一段都得是a ...

  8. Codeforces Round #119 (Div. 2)

    A. Cut Ribbon \(f(i)\)表示长为\(i\)的布条最多可以剪几段. B. Counting Rhombi \(O(wh)\)枚举中心计算 C. Permutations 将序列一映射 ...

  9. DP擎天

    DP! 黄题: 洛谷P2101 命运石之门的选择 假装是DP(分治 + ST表) CF 982C Cut 'em all! 树形贪心 洛谷P1020 导弹拦截 单调队列水题 绿题: 洛谷P1594 护 ...

随机推荐

  1. css3实现单行文本溢出显示省略号

    文本超出一定宽度让其隐藏,以省略号替代 width:200px; white-space:nowrap; text-overflow:ellipsis; overflow:hidden; 如下图

  2. windows平台在tomcat中启动cas报错解决

    windows平台在tomcat中启动cas报错: Caused by: java.lang.UnsatisfiedLinkError: Could not load library. Reasons ...

  3. C# RichTextBox插入带颜色数据

    #region 日志记录.支持其他线程访问 public delegate void LogAppendDelegate(Color color, string text); public void ...

  4. 29. SpringBoot Redis 非注解

    1. 引入依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spr ...

  5. ASP.NET MVC 3 笔记

    1.   MVC设计模式 Ø  Model:是指要处理的业务代码和数据操作代码. Ø  View:主要用于跟用户打交道,并能够展示数据. Ø  Controller:可以看作是 Model 和 Vie ...

  6. error.c

    #include <stdio.h> #include <errno.h> #include <stdlib.h> #include <string.h> ...

  7. 【bzoj 3173】[Tjoi2013]最长上升子序列

    Description 给定一个序列,初始为空.现在我们将1到N的数字插入到序列中,每次将一个数字插入到一个特定的位置.每插入一个数字,我们都想知道此时最长上升子序列长度是多少? Input 第一行一 ...

  8. 【BZOJ】2286: [Sdoi2011]消耗战 虚树+DP

    [题意]给定n个点的带边权树,每次询问给定ki个特殊点,求隔离点1和特殊点的最小代价.n<=250000,Σki<=500000. [算法]虚树+DP [题解]考虑普通树上的dp,设f[x ...

  9. js去掉某一属性

    将某一属性赋值为空就行了. 例如: document.getElementById('second').style.color = '';

  10. Hive思维导图