题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070

Milk

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14286    Accepted Submission(s):
3525

Problem Description
Ignatius drinks milk everyday, now he is in the
supermarket and he wants to choose a bottle of milk. There are many kinds of
milk in the supermarket, so Ignatius wants to know which kind of milk is the
cheapest.

Here are some rules:
1. Ignatius will never drink the milk
which is produced 6 days ago or earlier. That means if the milk is produced
2005-1-1, Ignatius will never drink this bottle after 2005-1-6(inclusive).
2.
Ignatius drinks 200mL milk everyday.
3. If the milk left in the bottle is
less than 200mL, Ignatius will throw it away.
4. All the milk in the
supermarket is just produced today.

Note that Ignatius only wants to buy
one bottle of milk, so if the volumn of a bottle is smaller than 200mL, you
should ignore it.
Given some information of milk, your task is to tell
Ignatius which milk is the cheapest.

 
Input
The input contains several test cases. The first line
of the input is a single integer T which is the number of test cases. T test
cases follow.
Each test case starts with a single integer N(1<=N<=100)
which is the number of kinds of milk. Then N lines follow, each line contains a
string S(the length will at most 100 characters) which indicate the brand of
milk, then two integers for the brand: P(Yuan) which is the price of a bottle,
V(mL) which is the volume of a bottle.
 
Output
For each test case, you should output the brand of the
milk which is the cheapest. If there are more than one cheapest brand, you
should output the one which has the largest volume.
 
Sample Input
2
2
Yili 10 500
Mengniu 20 1000
4
Yili 10 500
Mengniu 20 1000
Guangming 1 199
Yanpai 40 10000
 
Sample Output
Mengniu
Mengniu

Hint

In the first case, milk Yili can be drunk for 2 days, it costs 10 Yuan. Milk Mengniu can be drunk for 5 days, it costs 20 Yuan. So Mengniu is the cheapest.In the second case,
milk Guangming should be ignored. Milk Yanpai can be drunk for 5 days, but it costs 40 Yuan. So Mengniu is the cheapest.

 
 
题目大意:好久不做题目了,放松一段时间后,重整行囊,继续前行! 先做一水题找找感觉,没想到还找了好久0.0
这一题的要求:1、找到最便宜的牛奶 2、保质期只有五天(包含五天 ) 3、如果都是最便宜的话,要输出体积较大的
 
详见代码。
 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; int main()
{
char name[],min_name[];
double Min,s;
int min_v;
int T,p,v,d,n;
scanf("%d",&T);
while (T--)
{
Min=;
min_v=;
scanf("%d",&n);
while(n--)
{
scanf("%s%d%d",name,&p,&v);
if (v<)
continue;
if (v/>=)
s=p/;
else
s=p*1.0/(v/);
if(Min>s)
{
min_v=v;
Min=s;
strcpy(min_name,name);
}
else if(Min==s)
{
if(min_v<v)
{
min_v=v;
strcpy(min_name,name);
}
}
}
printf("%s\n",min_name);
}
return ;
}

hdu 1070 Milk(贪心)的更多相关文章

  1. HDU 1070 Milk (模拟)

    题目链接 Problem Description Ignatius drinks milk everyday, now he is in the supermarket and he wants to ...

  2. HDU 1070 - Milk

    给每种牛奶价格和量 要求买最便宜的牛奶 #include <iostream> using namespace std; int t,n; ][]; ],v[]; int main() { ...

  3. Hdu 4864(Task 贪心)(Java实现)

    Hdu 4864(Task 贪心) 原题链接 题意:给定n台机器和m个任务,任务和机器都有工作时间值和工作等级值,一个机器只能执行一个任务,且执行任务的条件位机器的两个值都大于等于任务的值,每完成一个 ...

  4. D - 淡黄的长裙 HDU - 4221(贪心)

    D - 淡黄的长裙 HDU - 4221(贪心) James is almost mad! Currently, he was assigned a lot of works to do, so ma ...

  5. HDOJ.1070 Milk(贪心)

    Milk 点我挑战题目 题意分析 每组测试数据给出一系列牛奶商品,分别是牛奶的品牌,价格,以及体积.在读取数据的时候,体积在200以下的牛奶直接忽略掉.并且每天要喝200ML的牛奶.但是无论牛奶体积有 ...

  6. hdu 2037简单贪心--活动安排问题

    活动安排问题就是要在所给的活动集合中选出最大的相容活动子集合,是可以用贪心算法有效求解的很好例子.该问题要求高效地安排一系列争用某一公共资源的活动.贪心算法提供了一个简单.漂亮的方法使得尽可能多的活动 ...

  7. HDU 4864 Task (贪心+STL多集(二分)+邻接表存储)(杭电多校训练赛第一场1004)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4864 解题报告:有n台机器用来完成m个任务,每个任务有一个难度值和一个需要完成的时间,每台机器有一个可 ...

  8. HDU 4310 Hero (贪心算法)

    A - Hero Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  9. hdu 4268 multiset+贪心

    Alice和Bob有n个长方形,有长度和宽度,一个矩形可以覆盖另一个矩形的条件的是,本身长度大于等于另一个矩形,且宽度大于等于另一个矩形,矩形不可旋转,问你Alice最多能覆盖Bob的几个矩形? /* ...

随机推荐

  1. HBase 所有命令解析

    COMMAND GROUPS:Group name: generalCommands: status, table_help, version, whoami Group name: ddlComma ...

  2. python获取本地时间

    python本地时间 import time # 格式化成2016-03-20 11:45:39形式 now = time.strftime("%Y-%m-%d %H:%M:%S" ...

  3. Angular-Cli中引用第三方库

    最近在学习angular(AngularJS 2),根据教程使用angular-cli新建项目, 然而在添加JQuery和Bootstrap第三方库时遇到了问题... 初试 我最初的想法是直接将相对路 ...

  4. 百度地图常用2.0使用以及调用js

    /** * 生成一条路线 * @param {Object} baiduMap 百度地图的 map对象 * @param {Object} lineColor 线路颜色 * @param {Objec ...

  5. Xcode开发技巧之code snippets(代码片段)

    一.什么是代码片段 当在Xcode中输入dowhile并回车后,Xcode会出现下图所示的提示代码: 这就是代码片段,目的是使程序员以最快的速度输入常用的代码片段,提高编程效率.该功能是从Xcode4 ...

  6. P4035 [JSOI2008]球形空间产生器

    题目描述 有一个球形空间产生器能够在 nn 维空间中产生一个坚硬的球体.现在,你被困在了这个 nn 维球体中,你只知道球面上 n+1n+1 个点的坐标,你需要以最快的速度确定这个 nn 维球体的球心坐 ...

  7. 协程简介-异步IO

    协程 1. 协程,又称微线程,纤程.协程是用户自己控制的,CPU根本不知道协程的存在,CPU只认识线程. 2. 线程切换的时候,会保存在CPU的寄存器里面. 协程切换的时候,却都是由用户自己的实现的. ...

  8. What’s That NetScaler Reset Packet?

    What’s That NetScaler Reset Packet? https://www.citrix.com/blogs/2014/05/20/whats-that-netscaler-res ...

  9. iphone手机与PC蓝牙出现感叹号且无法修复解决方案

    解决方案如下: 1.需要下载Windows Mobile 6.5 的驱动 drvupdate-amd64.exe ,下载需要正版验证,手动安装驱动,具体步骤Google 2. 如果在BlueTooth ...

  10. BZOJ4517 & 洛谷4071:[SDOI2016]排列计数——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=4517 https://www.luogu.org/problemnew/show/P4071 求有 ...