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;
    }
  • 相关阅读:
    mybatis动态SQl中int类型字段为0 SQl语句不拼接
    Ansible学习(pyenv与virtualenv)
    word
    github学习
    OpenStack搭建遇到的问题2(组件配置错误了,别重装全部,就把模块卸载就行了)
    OpenStack搭建遇到的问题
    Ubuntu 17.04 安装
    docker学习(一)
    MySQL安装
    来自Google的响应式——Agera
  • 原文地址:https://www.cnblogs.com/liyinggang/p/5701075.html
Copyright © 2011-2022 走看看