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 ...
随机推荐
- Windows安全认证是如何进行的?[Kerberos篇]
最近一段时间都在折腾安全(Security)方面的东西,比如Windows认证.非对称加密.数字证书.数字签名.TLS/SSL.WS-Security等.如果时间允许,我很乐意写一系列的文章与广大网友 ...
- 在C#中,为什么大家用httpcontext.current,不直接用HttpContext
HttpContext只是个类名,HttpContext.Current才是一个已实例化的对象..比如这样一个类: class A{ public static A Current{get;set;} ...
- spring双列
public class MyCollection { private String[]array; private List<String>list; priv ...
- 妙用Object
妙用Object 当你在写C#程序时,经常会用到“ToString()”这个方法,而且如果你细心你点就会发现所有的引用类型都含有“ToString()”这个方法,那么你知道为什么会这样吗?很简单,因为 ...
- Sublime常用插件安装大全
作为前端人员,要找一个很顺手的编辑器真的不容易,我向大家推荐的一款实用前端开发神器,不但占地小,且插件很多,很强大. 下面我向大家介绍一下它的安装及插件的使用方法. 一.安装及安装emmet插件 首先 ...
- Struts2初级篇(HelloWorld)
Struts2的工作流程: 从一个高水平角度看,Struts2 是一个MVC拉动的(或MVC2)框架,Struts2 的模型-视图-控制器模式是通过以下五个核心部分进行实现的: 操作(Actions) ...
- 配置Linux环境
安装mariadb +主从复制https://www.cnblogs.com/pyyu/p/9467289.html 参考博客 redis https://www.cnblogs.com/pyyu/p ...
- ABAP ICON
1.输出图标的3种方法 WRITE: / '@09@'. "id WRITE: / icon_yellow_light. "name WRITE: / '@S_TL_Y@'. &q ...
- 关于echarts和jqeury的结合使用问题
今天在工作上遇到了一个小问题,就是自己在用echarts渲染了一个柱状图,然后点击其他位置,将渲染echart的div进行了清空,这里我所有的echart图形都是在同一个div中渲染的,然后当再次要求 ...
- 初识Notification
通知(Notification)是 Android 系统中比较有特色的一个功能,当某个应用程序希望向用户发出一些提示信息,而该应用程序又不在前台运行时,就可以借助通知来实现.发出一条通知后,手机最上方 ...