博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces 919 A. Supermarket
阅读量:5110 次
发布时间:2019-06-13

本文共 2369 字,大约阅读时间需要 7 分钟。

这场cf有点意思,hack场,C题等于1的特判hack很多人(我hack成功3个人,上分了,哈哈哈,咳咳。。。) 

D题好像是树形dp,E题好像是中国剩余定理,F题好像还是dp,具体的不清楚,最近dp的题目好多,一会滚去学dp。

写A,B,C的题解。

 

A. Supermarket
 
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

 

大水题。

 

代码:

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 using namespace std;14 const int inf=0x3f3f3f3f;15 int main(){16 double a,b,ans;17 double minn=inf;18 int n,m;19 cin>>n>>m;20 for(int i=0;i
>a>>b;22 if(minn>a/b) minn=1.0*a/b;23 }24 ans=minn*(double)m;25 printf("%.8lf",ans);26 }

 

 

 

 

 

 

 

滚去学dp,学会了补后面的题|ू・ω・` )

 

 

转载于:https://www.cnblogs.com/ZERO-/p/8401284.html

你可能感兴趣的文章
PHP反射类的理解(代码篇)
查看>>
怎么安装Apache,php,mysql (二)——php和apache怎么配置mysql?
查看>>
android:hint属性对TextView的影响
查看>>
opencv源代码分析:icvGetTrainingDataCallback简单介绍
查看>>
MVC返回JSON,IE下无法接收JSON,IE下JSON提示另存为
查看>>
Python元类(metaclass)以及元类实现单例模式
查看>>
Codeforces.GYM101612E.Equal Numbers(贪心)
查看>>
树莓派开启SSH
查看>>
大数据Hadoop Hive HBase Spark Storm
查看>>
eclipse中安装Open Explorer
查看>>
关于数组比较
查看>>
求期望 ZOJ 3329 One Person Game
查看>>
Tcp连接的七次握手浅析
查看>>
开源框架.netCore DncZeus学习(三)增加一个菜单
查看>>
[SDOI2019]世界地图(kruskal重构树+虚树)
查看>>
使用C#通过调用minitab的COM库自动化生成报表
查看>>
(三)、
查看>>
linux输入子系统之按键驱动
查看>>
SVN提交文件失败:系统找不到指定路径
查看>>
团队组建的一些想法
查看>>