首页 > 其他 > 详细

hdu 5190(水题)

时间:2016-07-24 17:53:23      阅读:268      评论:0      收藏:0      [点我收藏+]

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\n",MIN);
    }
    return 0;
}

 

hdu 5190(水题)

原文:http://www.cnblogs.com/liyinggang/p/5701075.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!