zoukankan      html  css  js  c++  java
  • hdu 5190(水题)

    Go to movies

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 1029    Accepted Submission(s): 543


    Problem Description
    Winter holiday is coming!As the monitor, LeLe plans to go to the movies.
    Because the winter holiday tickets are pretty expensive, LeLe decideds to try group-buying.
     
    Input
    There are multiple test cases, about 20 cases. The first line of input contains two integers n,m(1n,m100). n indicates the number of the students. m indicates how many cinemas have offered group-buying.

    For the m lines,each line contains two integers ai,bi(1ai,bi100), indicating the choices of the group buying cinemas offered which means you can use bi yuan to buy ai tickets in this cinema.
     
    Output
    For each case, please help LeLe **choose a cinema** which costs the least money. Output the total money LeLe should pay.
     
    Sample Input
    3 2 2 2 3 5
     
    Sample Output
    4
    Hint
    LeLe can buy four tickets with four yuan in cinema 1.
     
    Source
     
    题意:在 m 个电影院选择一家进行团购,团购规则是 b 元买 a 张票,问买 n 张票所需的最少钱?
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include <algorithm>
    #include <math.h>
    using namespace std;
    typedef long long LL;
    int main()
    {
        int n,m;
        while(scanf("%d%d",&n,&m)!=EOF){
            int MIN = 999999999;
            for(int i=1;i<=m;i++){
                int a,b;
                scanf("%d%d",&a,&b);
                int k = n/a+((n%a==0)?0:1);
                MIN = min(MIN,b*k);
            }
            printf("%d
    ",MIN);
        }
        return 0;
    }
  • 相关阅读:
    Java之final关键字
    Java之代码块
    Java之单例设计模式
    Java之数组
    python基础知识第九篇(函数)
    css--属性
    css-选择器
    css--引入css的3种方法
    html--多选
    python-列表--处理
  • 原文地址:https://www.cnblogs.com/liyinggang/p/5701075.html
Copyright © 2011-2022 走看看