Codeforces Round #460 (Div. 2)-A. Supermarket
A. Supermarket
time limit per test2 seconds
memory limit per test256 megabytes
Problem Description
We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for b kilos (You don’t need to care about what “yuan” is), the same as a / b yuan for a kilo.
Now imagine you’d like to buy m kilos of apples. You’ve asked n supermarkets and got the prices. Find the minimum cost for those apples.
You can assume that there are enough apples in all supermarkets.
Input
The first line contains two positive integers n and m (1 ≤ n ≤ 5 000, 1 ≤ m ≤ 100), denoting that there are n supermarkets and you want to buy m kilos of apples.
The following n lines describe the information of the supermarkets. Each line contains two positive integers a, b (1 ≤ a, b ≤ 100), denoting that in this supermarket, you are supposed to pay a yuan for b kilos of apples.
Output
The only line, denoting the minimum cost for m kilos of apples. Please make sure that the absolute or relative error between your answer and the correct answer won’t exceed 10 - 6.
Formally, let your answer be x, and the jury’s answer be y. Your answer is considered correct if .
Examples
input
3 5
1 2
3 4
1 3
output
1.66666667
input
2 1
99 100
98 99
output
0.98989899
解题心得:
- 一个水题,注意精度问题就可以轻松过了。
#include<bits/stdc++.h>
using namespace std;
int main()
{
double ans,a,b,m;
int n;
scanf("%d%lf",&n,&m);
ans = 10000000.0;
for(int i=0;i<n;i++)
{
scanf("%lf%lf",&a,&b);
ans = min(ans,m*a/b);
}
printf("%.8f",ans);
return 0;
}
Codeforces Round #460 (Div. 2)-A. Supermarket的更多相关文章
- 【Codeforces Round #460 (Div. 2) A】 Supermarket
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 就是让你求m*(ai/bb)的最小值 [代码] #include <bits/stdc++.h> #define dou ...
- Codeforces Round #460 (Div. 2) ABCDE题解
原文链接http://www.cnblogs.com/zhouzhendong/p/8397685.html 2018-02-01 $A$ 题意概括 你要买$m$斤水果,现在有$n$个超市让你选择. ...
- Codeforces Round #460 (Div. 2)
A. Supermarket We often go to supermarkets to buy some fruits or vegetables, and on the tag there pr ...
- [Codeforces]Codeforces Round #460 (Div. 2)
Supermarket 找最便宜的就行 Solution Perfect Number 暴力做 Solution Seat Arrangement 注意当k=1时,横着和竖着是同一种方案 Soluti ...
- Codeforces Round #460 (Div. 2) E. Congruence Equation (CRT+数论)
题目链接: http://codeforces.com/problemset/problem/919/E 题意: 让你求满足 \(na^n\equiv b \pmod p\) 的 \(n\) 的个数. ...
- Codeforces Round #460 (Div. 2)-A Supermaket(贪心)
A. Supermarket time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #460 (Div. 2) 前三题
Problem A:题目传送门 题目大意:给你N家店,每家店有不同的价格卖苹果,ai元bi斤,那么这家的苹果就是ai/bi元一斤,你要买M斤,问最少花多少元. 题解:贪心,找最小的ai/bi. #in ...
- Codeforces Round #460 (Div. 2): D. Substring(DAG+DP+判环)
D. Substring time limit per test 3 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #460 (Div. 2).E 费马小定理+中国剩余定理
E. Congruence Equation time limit per test 3 seconds memory limit per test 256 megabytes input stand ...
随机推荐
- Maven的学习资料收集--(七) 构建Spring项目
在这里,使用Maven构建一个Spring项目 构建单独项目的话,其实都差不多 1. 新建一个Web项目 参考之前的博客 2.修改 pom.xml,添加Spring依赖 <project xml ...
- Docker | 第七章:Docker Compose服务编排介绍及使用
前言 前面章节,我们学习了如何构建自己的镜像文件,如何保存自己的镜像文件.大多都是一个镜像启动.当一个系统需要多个子系统进行配合时,若每个子系统也就是镜像需要一个个手动启动和停止的话,那估计实施人员也 ...
- JS语法字典---网友总结
1.document.write(""); 输出语句2.JS中的注释为//3.传统的HTML文档顺序是:document->html->(head,body)4.一个浏 ...
- instancetype和id的区别,objective-c
instancetype clang 3.5 提供的关键字, 表示:某方法返回未知类型的OC对象 都知道id任意类型关键字,为什么还会出现一个新的关键字? 返回关联类型 1.类方法中,alloc ...
- Eucalyptus常用查询命令
前言: Elastic Utility Computing Architecture for Linking Your Programs To Useful Systems (Eucalyptus) ...
- Hibernate数据库的操作
参考网址: https://www.cnblogs.com/jack1995/p/6952704.html 1.最简单的查询 List<Special> specials = (List& ...
- 【extjs6学习笔记】1.9 初始: Mixins
Mixin允许我们使用一个类的函数作为另一个类的函数而不继承. Mixins可以使用mixins关键字定义,并将值指定为JSON对象,其中属性的名称应该是要使用的方法的名称,属性的值将是定义方法的类的 ...
- python logging 模块记录日志
#日志记录到多文件示例 import logging def error_log(message): file_1_1 = logging.FileHandler('error.log', 'a+', ...
- GBase数据库存储过程——批量删除多个数据表的数据
偶尔需要清空一下数据库,重装成本太高. --清空历史存储过程 DROP Procedure `dap_model`.`delete_datas` ; --创建存储过程 DELIMITER // CRE ...
- Android商城开发系列(十)—— 首页活动广告布局实现
在上一篇博客当中,我们讲了频道布局的实现,接下来我们讲解一下活动广告布局的实现,效果如下图: 这个是用viewpager去实现的,新建一个act_item.xml,代码如下所示: <?xml v ...