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 i 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;
}