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 ...
随机推荐
- Docker | 第零章:前言
说在前面 对于一个后端开发者而言,对于Docker也是前年十月份才开始听说的(很惭愧,Docker在2013年就已经出现了).当时有个新项目启动,领导们在技术选型时,在部署方面选定的是Docker.那 ...
- 搭建Node.js Redis开发环境
创建项目 初始化为node项目 $npm init 安装redis 安装@types/node, @types/redis, typescript 初始化TypeScript 配置ts ...
- Vue小贴士
1.去掉空格影响,删除掉此段代码 2.想要同时运行两个Vue项目,修改端口号,黄色框内的内容自己随意改个端口号就行,比如:8082 3.批处理 在项目的根目录中添加a.bat文件,这样就可以在运行的 ...
- NopI 导出数据
protected void exportAward(DataSet dsResult) { if (dsResult != null) { string fileName = System.Web. ...
- 30分钟学会React Hook, Memo, Lazy
我们来学习React 16.8里的新特性. 1. 自行配置好React的环境,推荐你使用Create React APP, 你也可以下载本文档Zip解压到本地直接运行. https://github. ...
- 大数据kafka视频教程 学习记录【B站尚硅谷 】
视频地址: https://www.bilibili.com/video/av35354301/?p=1 2019/03/06 21:59 消息队列的内部实现: Kafka基础: ...
- swift学习笔记7
不管做什么事,只要敬业点,把该作的做好.不要总找借口. 不要看不起小事,生活本是一件件小事的集合.细节决定成败. 士兵突击里面有句台词:他每做一件小事的时候,都好像抓住了一根救命稻草,到最后你才发现, ...
- 从零开始的全栈工程师——js篇2.7(JS数据类型具体分析)
JS数据类型具体分析与数据的三大存储格式 1. 字符串 string2. 数字 number3. 布尔 boolean4. null 空5. undefined 未定义↑↑↑叫基本数据类型 基本数据类 ...
- 使用create react app教程
This project was bootstrapped with Create React App. Below you will find some information on how to ...
- Android rxjava2的disposable
rxjava+retrofit处理网络请求 在使用rxjava+retrofit处理网络请求的时候,一般会采用对观察者进行封装,实现代码复用和拓展.可以参考我的这篇文章:rxjava2+retrofi ...