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;
}
最新文章
- python 学习笔记 -logging模块(日志)
- Get-FilewithExtension
- 深度学习 - DL
- C++中的4个类型转换关键字
- Python时区转换
- 利用bak文件恢复数据库问题小结
- bash可改动的环境变量
- 如何“任性”使用Android的drawText()
- 数组排序-Objectivec
- windows c++程序移植到linux的要点
- 51-迷宫(一)- java版dfs和bfs
- topcoder srm 570 div1
- Python崛起:“人生苦短,我用Python”并非一句戏言
- Linux第七周学习总结——可执行程序的装载
- WordPress主题开发:循环代码
- Javascript中的继承与Prototype
- 配置idea
- C/C++ 获取目录下的文件列表信息
- [LeetCode] 数学计算模拟类问题:加法,除法和幂,注意越界问题。题 剑指Offer,Pow(x, n) ,Divide Two Integers
- vue 阻止表单默认事件