zoukankan      html  css  js  c++  java
  • 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


    解题心得:

    1. 一个水题,注意精度问题就可以轻松过了。

    #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;
    }
  • 相关阅读:
    如何理解cat的输入输出重定向
    Vagrant网络设置
    Vagrant入门
    设计模式的原则
    单例模式
    LRU 实现缓存
    java注解
    java8---lambda表达式
    JUC--Callable 以及Lock同步锁
    JUC--闭锁 CountDownLatch
  • 原文地址:https://www.cnblogs.com/GoldenFingers/p/9107182.html
Copyright © 2011-2022 走看看