题目链接:http://vjudge.net/contest/139376#problem/E

题意看注释就能懂了,求能获得的最大价值。

代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std; int dp[]; int n,m,p,q; ///n面粉的重量 m是stuff的种类,p是生产馒头需要的淀粉的质量,q是馒头能卖的钱数
/// m组数 剩下a g stuff need stuff b stuff c g面粉 价值d int main()
{
while(scanf("%d%d%d%d",&n,&m,&p,&q)==)
{
memset(dp,,sizeof(dp));
for(int i=; i<=n; i++)
dp[i]=(i/p)*q;
int a,b,c,d;
for(int k=; k<=m; k++)
{
scanf("%d%d%d%d",&a,&b,&c,&d);
for(int i=; i<=a/b; i++)
for(int j=n; j>=c; j--)
dp[j]=max(dp[j],dp[j-c]+d);
}
printf("%d\n",dp[n]);
}
return ;
}

cf 106C的更多相关文章

  1. CF dp 题(1500-2000难度)

    前言 从后往前刷 update 新增 \(\text{\color{red}{Mark}}\) 标记功能,有一定难度的题标记为 \(\text{\color{red}{红}}\) 色. 题单 (刷过的 ...

  2. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  3. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  4. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  5. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  6. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  7. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  8. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

  9. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

随机推荐

  1. pthread_cond_wait的原子性

    使用的基本模板如下(参考APUE): signal代码序列如下, pthread_mutex_lock ... pthread_cond_signal pthread_mutex_unlock   w ...

  2. hdu 1896.Stones 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1896 题目意思:给出 n 块石头的初始位置和能到达的距离.对于第奇数次遇到的石头才抛掷,偶数次的就忽略 ...

  3. 【leetcode】Distinct Subsequences(hard)

    Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...

  4. 【XLL API 函数】xlGetName

    以字符串格式返回 DLL 文件的长文件名. 原型 Excel12(xlGetName, LPXLOPER12 pxRes, 0); 参数 这个函数没有参数 属性值和返回值 返回文件名和路径 实例 \S ...

  5. JDBC题库

    一.    填空题 JDBC    ,是一种用于执行SQL语句的Java API,为多种关系数据库提供统一访问.它由一组用Java语言编写的类和接口组成. JDBC API:供程序员调用的接口与类,集 ...

  6. UISearchController Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior

    Attempting to load the view of a view controller while it is deallocating is not allowed and may res ...

  7. Ios cordova安装

    安装NODEJS:http://nodejs.org/ (如果你安装了旧版本的需要手动安装npm,不过最新版的自带了) 进入终端命令行使用npm安装cordova如下: $ sudo npm inst ...

  8. MongoDB 3.0(1):CentOS7 安装MongoDB 3.0服务

    目录(?)[-] 1下载安装 2MongoDB CRUD 1创建数据 2更新数据 3删除 4查询 5更多方法 3MongoDB可视化工具 4总结   本文原文连接: http://blog.csdn. ...

  9. 容器配置jndi Tomcat为例

    context.xml 文件 <Resource name=" password="spsj" type="javax.sql.DataSource&qu ...

  10. codevs 2851 菜菜买气球

    dp加二分法 链接:http://codevs.cn/problem/2851/ #include<iostream> #include<vector> #include< ...