HDU1070Milk
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
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
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
Sample Input
Sample Output
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.
题意:这个人每天喝200ml,一次牛奶最多喝5天,求性价比最高的牛奶
#include<bits/stdc++.h>
using namespace std;
struct Node {
string s;
int mol;
int ml;
double rate;
} aa[];
int main() {
int t;
cin>>t;
while(t--) {
int n;
cin>>n;
for(int i=; i<n; i++) {
cin>>aa[i].s>>aa[i].mol>>aa[i].ml;
if(aa[i].ml>=)
aa[i].rate=aa[i].mol/;
else if(aa[i].ml>=) {
int x=aa[i].ml/;
aa[i].rate=aa[i].mol/(double)(x*1.0);
} else
aa[i].rate=-;
}
double minn=0x1f1f1f1f;
int k;
for(int j=; j<n; j++) {
if(aa[j].rate!=-) {
if(aa[j].rate!=-) {
if(aa[j].rate<minn) {
minn=aa[j].rate;
k=j;
}
}
}
}
cout<<aa[k].s<<endl;
}
return ;
}
HDU1070Milk的更多相关文章
随机推荐
- Ubuntu 14.04 安装flash插件
分别tar.gz和apt-get方法 第一种: adboe官网下载tar.gz,进入terminal 1.解压缩包,输入命令“tar -zxvf 软件包名字” 2.拷贝插件到mozilla目录,输入命 ...
- 在Nginx 下运行 Laravel5.1 的配置
一.nginx 的 vhost.conf 配置: server { listen ; server_name sub.domain.com; set $root_path '/srv/www/defa ...
- 自定义Toast的显示效果
Activity: package com.example.editortoast; import android.app.Activity; import android.os.Bundle; im ...
- STM32F0xx_DMA收发USART数据配置详细过程
前言 关于DMA(Direct Memory Access)的功能,前面关注我微信的人应该知道,其实我已经在F1芯片上简单讲了一下.有网友要求在F0讲解一下使用DMA收发串口数据.今天就应网友要求总结 ...
- wpf做的可扩展记事本
记得有个winform利用反射做的可扩展笔记本,闲来无事,便用wpf也搞了个可扩展记事本,可用接口动态扩展功能,较简单,以便参考: 目录结构如下: MainWindow.xaml为主功能界面,Func ...
- 自己的php函数库
//判断数组中是否有元素为空的函数,支持多维数组,相似系统函数in_array(value,array,type) function is_null_array($arr) { if(!is_arra ...
- nginx 配置 ThinkPHP Rewrite
server { listen 80; server_name www.funsion.com; root /www/web/funsion; index index.php; location / ...
- poj 3061 Subsequence
题目连接 http://poj.org/problem?id=3061 Subsequence Description A sequence of N positive integers (10 &l ...
- net-snmp的安装
安装环境是ubuntu 14. 方法1:apt-get install net-snmp (非root用户需要sudo 提升权限) 方法2:自定义安装选择不同的版本去编译. 1:先去下载所需要的ta ...
- 管理员必备的20个Linux系统监控工具
需要监控Linux服务器系统性能吗?尝试下面这些系统内置或附件的工具吧.大多数Linux发行版本都装备了大量的监控工具.这些工具提供了能用作取得相关信息和系统活动的量度指标.你能使用这些工具发现造成性 ...