码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 5190(水题)

时间:2016-07-24 17:54:45      阅读:130      评论: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(1≤n,m≤100). 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(1≤ai,bi≤100), 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)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!