zoukankan      html  css  js  c++  java
  • Codeforces 919 A. Supermarket

    这场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<iostream>
     2 #include<cstdio>
     3 #include<algorithm>
     4 #include<cstring>
     5 #include<cstdlib>
     6 #include<string.h>
     7 #include<set>
     8 #include<vector>
     9 #include<queue>
    10 #include<stack>
    11 #include<map>
    12 #include<cmath>
    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<n;i++){
    21         cin>>a>>b;
    22         if(minn>a/b) minn=1.0*a/b;
    23     }
    24     ans=minn*(double)m;
    25     printf("%.8lf",ans);
    26 }
     

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

  • 相关阅读:
    ubuntu删除django和安装django
    linux shell 统计文件单词出现次数
    linux shell $$、$!特殊符号
    linux安装zabbix需要php两个模块php-bcmach与php-mbstring
    linux 源码编译与卸载
    Job for dhcpd.service failed because the control process exited with error code. See "systemctl status dhcpd.service" and "journalctl -xe" for details.问题
    Linux中部署DNS分离解析技术
    NFS网络文件系统服务搭建
    Samba服务搭建
    Linux RAID磁盘阵列技术
  • 原文地址:https://www.cnblogs.com/ZERO-/p/8401284.html
Copyright © 2011-2022 走看看