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 = ;
for(int i=;i<=m;i++){
int a,b;
scanf("%d%d",&a,&b);
int k = n/a+((n%a==)?:);
MIN = min(MIN,b*k);
}
printf("%d\n",MIN);
}
return ;
}

hdu 5190(水题)的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  3. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  4. HDU排序水题

    1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...

  5. hdu 2710 水题

    题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...

  6. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  7. hdu 5162(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...

  8. hdu 3357 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...

  9. hdu 5038 水题 可是题意坑

    http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数  这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心  If not all ...

随机推荐

  1. html页面简单制作示例

    内有表格布局,具体见 链接: https://pan.baidu.com/s/1V7IcxQ5M-iXVdlzuf8bo-A 密码: 8dp8

  2. OJ题归纳

    1.求最大公约数 利用辗转相除法求最大公约数 int gcd(int a,int b) { int c,r; if(a<b){c=a;a=b;b=c;} if(b==0) return a; r ...

  3. windows下eclipse连接ubuntu伪分布式hadoop2.6.0

    环境: win10 jdk1.7 hadoop2.6.0 linux虚拟机 Ubuntu14.04 首先把安装在Ubuntu上的hadoop2.6.0.tar.gz复制到windows系统上,解压到任 ...

  4. [剑指Offer] 19.顺时针打印矩阵

    [思路]本题关键在于 右->左 和 下->上 两个循环体中的判断条件,即判断是否重复打印. class Solution { public: vector<int> print ...

  5. Hadoop上配置Hbase数据库

    已有环境: 1. Ubuntu:14.04.2 2.jdk: 1.8.0_45 3.hadoop:2.6.0 4.hBase:1.0.0 详细过程: 1.下载最新的Hbase,这里我下载的是hbase ...

  6. Thymeleaf 如何支持java8的时间LocalDate和LocalDatetime

    一.添加依赖 <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thym ...

  7. [洛谷P1420]最长连号

    题目大意:输入$n$个正整数,($1\leq n\leq 10000$),要求输出最长的连号的长度.(连号指从小到大连续自然数) 题解:考虑从小到大连续自然数差分为$1$,所以可以把原数列差分(后缀自 ...

  8. POJ 3415 后缀数组+单调栈

    题目大意: 给定A,B两种字符串,问他们当中的长度大于k的公共子串的个数有多少个 这道题目本身理解不难,将两个字符串合并后求出它的后缀数组 然后利用后缀数组求解答案 这里一开始看题解说要用栈的思想,觉 ...

  9. AOJ.602 大家来找茬

    大家来找茬 Time Limit: 1000 ms Case Time Limit: 1000 ms Memory Limit: 64 MB Total Submission: 627 Submiss ...

  10. 【CF Round 434 A. k-rounding】

    Time limit per test1 second memory limit per test 256 megabytes input standard input output standard ...