A - Supermarket
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
Note
In the first sample, you are supposed to buy 5 kilos of apples in supermarket 3. The cost is 5 / 3 yuan.
In the second sample, you are supposed to buy 1 kilo of apples in supermarket 2. The cost is 98 / 99 yuan.
解题思路:题目的意思就是选择去单价最小的超市,注意用double类型,然后购买m千克,即为最小需付金额,水过。
AC代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;double a,b,pay=200.0;
cin>>n>>m;
while(n--){
cin>>a>>b;
if(a/b<pay)pay=a/b;
}
printf("%.8f\n",m*pay);
return ;
}
A - Supermarket的更多相关文章
- POJ 1456 Supermarket 区间问题并查集||贪心
F - Supermarket Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Sub ...
- Supermarket POJ - 1456
A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold ...
- codeforces 815C Karen and Supermarket
On the way home, Karen decided to stop by the supermarket to buy some groceries. She needs to buy a ...
- codeforces round #419 E. Karen and Supermarket
On the way home, Karen decided to stop by the supermarket to buy some groceries. She needs to buy a ...
- Codeforces 815C Karen and Supermarket 树形dp
Karen and Supermarket 感觉就是很普通的树形dp. dp[ i ][ 0 ][ u ]表示在 i 这棵子树中选择 u 个且 i 不用优惠券的最小花费. dp[ i ][ 1 ][ ...
- G - Supermarket
A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold ...
- POJ 1456 - Supermarket - [贪心+小顶堆]
题目链接:http://poj.org/problem?id=1456 Time Limit: 2000MS Memory Limit: 65536K Description A supermarke ...
- CF815C Karen and Supermarket
题目链接 CF815C Karen and Supermarket 题解 只要在最大化数量的前提下,最小化花费就好了 这个数量枚举ok, dp[i][j][1/0]表示节点i的子树中买了j件商品 i ...
- POJ-1456 Supermarket(贪心,并查集优化)
Supermarket Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10725 Accepted: 4688 Descript ...
- NYOJ 208 Supermarket (模拟+并查集)
题目链接 描述 A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Pr ...
随机推荐
- [C++] 配平化学方程式算法的封装
有人已经实现了配平的方法,在此不再重复介绍. https://www.cnblogs.com/Elfish/p/7631603.html 但是,上述的方法所提供的代码还是存在着问题,需要进一步修改. ...
- [BZOJ 4999]This Problem Is Too Simple!
[BZOJ 4999]This Problem Is Too Simple! 题目 给您一颗树,每个节点有个初始值. 现在支持以下两种操作: 1. C i x(0<=x<2^31) 表示将 ...
- 用c++编程:用两个栈实现队列
栈s1和栈s2,栈s1专门为入队,栈s2专门为出队. 入队: 当s1和s2都为空时,直接入队s1. 当s1为空,s2不为空时,把s2的元素都倒回s1,然后再入队s1 出队: 当s2不为空时,直接出队s ...
- B - Oulipo
The French author Georges Perec (1936�C1982) once wrote a book, La disparition, without the letter ' ...
- Windows超级卸载工具Total Uninstaller,能完全卸载.NET Framework
https://github.com/tsasioglu/Total-Uninstaller
- 网易杭研后台技术中心的博客 -MYSQL :OOM
http://backend.blog.163.com/blog/#m=0&t=3&c=mysql
- Android:创建ZeroMQ的客户端
这里我们将给出一个subscribe模式的客户端示例程序,如下: private class ZeroMQMessageTask extends AsyncTask<String, Void, ...
- LA 3695 部分枚举
运用部分枚举的思想,很明显完全枚举点的思想是不可能的.改为枚举上下边界,当确定右边界j后,对左边界i,可以有点数为on[j]+on[i]+(leftu[j]-leftu[i])+leftd[j]-le ...
- [Android L or M ]解除SwitchPreference与Preference的绑定事件
需求描写叙述 默认情况,Android的两个控件SwitchPreference和CheckBoxPreference的事件处理是和Preference整个区域的事件绑定在一起的,然而,有时须要将其事 ...
- JSP 获取Request 经常使用參数
<input type="hidden" id="a" value="<%=request.getScheme()%>" ...