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;
    }
  • 相关阅读:
    Django项目实战之用户头像上传与访问
    ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
    《http权威指南》读书笔记13
    《http权威指南》读书笔记12
    《http权威指南》读书笔记11
    《http权威指南》读书笔记10
    《http权威指南》读书笔记9
    移动端帧动画抖动解决方案
    display: table-cell的实用应用
    《http权威指南》读书笔记8
  • 原文地址:https://www.cnblogs.com/GoldenFingers/p/9107182.html
Copyright © 2011-2022 走看看