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;
    }
  • 相关阅读:
    android LinearLayout设置selector不起作用解决
    LinearLayout 垂直滚动条
    安卓如何限制横屏和竖屏
    Android特效 五种Toast详解
    打开MySQL数据库远程访问的权限
    android edittext不弹出软键盘
    高速掌握Lua 5.3 —— 扩展你的程序 (1)
    10分钟-jQuery过滤选择器
    2014年软件设计师考试后记
    Spring监管下的Hibernate配置文件
  • 原文地址:https://www.cnblogs.com/GoldenFingers/p/9107182.html
Copyright © 2011-2022 走看看