Business Center

Time Limit: 1000ms
Memory Limit: 65536KB

This problem will be judged on PKU. Original ID: 3863
64-bit integer IO format: %lld      Java class name: Main

 
International Cyber Police Corporation (ICPC) had built a new mega-tall business center to host its headquarters and to lease some space for extra profit. It has so many floors, that it is impractical to have a separate button in each of its m elevator cars for each individual floor. Instead, each elevator car has just two buttons. One button in i-th elevator car makes it move up ui floors, the other makes it move down di floors. The business center is so high, that we can ignore its height for this problem (you will never reach the top floor), but you cannot go below the ground floor. All floors are numbered by integer numbers starting from zero, zero being the ground floor. 
You start on the ground floor of the business center. You have to choose one elevator car out of m to ride on. You cannot switch elevators cars after that. What is the lowest floor above the ground floor you can get to after you press elevator car buttons exactly n times?

 

Input

The first line of the input file contains two integer numbers n and m (1 <= n <= 1 000 000, 1 <= m <= 2 000) - the number of button presses and the number of elevator cars to choose from. The following m lines describe elevator cars. Each line contains two integer numbers ui and di (1 <= ui, di <= 1 000).

 

Output

Write to the output file a single positive integer number - the number of the lowest floor above ground floor that can be reached by one of m elevators after pressing its buttons exactly n times.

 

Sample Input

10 3
15 12
15 4
7 12

Sample Output

13

Source

 
解题:直接搞呗。。貌似要求必须至少上一次
 #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,m,u,d,ret;
void check() {
LL tmp = (n*d+u+d)/(u+d);
ret = min(ret,(u+d)*tmp - n*d);
}
int main() {
ios::sync_with_stdio(false);
cin>>n>>m;
ret = INT_MAX;
while(m--) {
cin>>u>>d;
check();
}
cout<<ret<<endl;
return ;
}

POJ 3863 Business Center的更多相关文章

  1. UVa 1648 (推公式) Business Center

    题意: 有一种奇怪的电梯,每次只能向上走u个楼层或者向下走d个楼层 现在有m个这种电梯,求恰好n次能够到达的最小楼层数(必须是正数),最开始默认位于第0层. 分析: 假设电梯向上走x次,则向下走n-x ...

  2. BZOJ 4159 [Neerc2009]Business Center

    思路 简单的模拟,答案就是\(min\{(\lfloor\frac{d\times n}{u+d}\rfloor+1)\times(u+d)-d\times n\}\) 代码 #include < ...

  3. UVA 1648 Business Center

    https://vjudge.net/problem/UVA-1648 设上升x层,列个方程解出来,再把x带回去 #include<cmath> #include<cstdio> ...

  4. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  5. 2015 UESTC Winter Training #10【Northeastern Europe 2009】

    2015 UESTC Winter Training #10 Northeastern Europe 2009 最近集训都不在状态啊,嘛,上午一直在练车,比赛时也是刚吃过午饭,状态不好也难免,下次比赛 ...

  6. Angular material mat-icon 资源参考_Places

    ul,li>ol { margin-bottom: 0 } dt { font-weight: 700 } dd { margin: 0 1.5em 1.5em } img { height: ...

  7. Inventor2018专业版软件安装激活教程

    如果你安装的是Autodesk Inventor Professional 2018,那么序列号为:666-69696969,产品密钥为:797J1, 如果你安装的是Autodesk Inventor ...

  8. OptaPlanner 7.32.0.Final版本彩蛋 - SolverManager之异步求解

    因为工作和其它原因,很长一段时间没有出新的.关于OptaPlanner的文章了,但工余时间并没有停止对该引擎的学习.与此同时Geoffrey大神带领的KIE项目团队并没有闲下来,尽管在工业可用性.易用 ...

  9. POJ 2774 Long Long Message 后缀数组

    Long Long Message   Description The little cat is majoring in physics in the capital of Byterland. A ...

随机推荐

  1. 使用python绘制词云

    最近在忙考试的事情,没什么时间敲代码,一个月也没几天看代码,最近看到可视化的词云,看到网上也很多这样的工具, 但是都不怎么完美,有些不支持中文,有的中文词频统计得莫名其妙.有的不支持自定义形状.所有的 ...

  2. laravel 5.5 项目报错

    报错内容: ErrorException (E_WARNING) Declaration of App\Observers\SiteObserver::updated($site) should be ...

  3. hadoop从wordCount开始

    最近一段时间大数据很火,我有稍微有点java基础,自然选择了由java编写的hadoop框架,wordCount是hadoop中类似于java中helloWorld的存在,自然不能错过. packag ...

  4. axios 使用post方式传递参数,后端接受不到问题

    一.URLSearchParams var params = new URLSearchParams(); params.append('key1', 'value1'); //你要传给后台的参数值 ...

  5. PCA一些性质的定性理解

    1.通过本征向量和本征值求主成分 关系:本征值是本征向量的缩放倍数,本征值大的对应的本征向量上的样本的数目就越多:相反本征值越小的,就本征向量上的样本数量就会少.因此可以求出PCA的主成分 主成分分析 ...

  6. axios简单封装

    写在最前面 新手前端刚刚接触vue,感觉真的好用.项目中需要使用axios,然后学习了一下.借鉴网上一些大佬的经验,现在分享一下axios的简单封装,如果有什么错误的地方,请大家指出. axios安装 ...

  7. 紫书 例题11-11 UVa 12661 (dihkstra变形)

    这道题主要比较权值的时候要改变一下,其他地方基本一样. 比较权值的时候要考虑边的时间与a, b 可以设相对于当前边的时间now, 则now = d[u] % (a+b), 也就是当前这个边进行到整个a ...

  8. 【BZOJ 1293】[SCOI2009]生日礼物

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然的滑动窗口题. (尺取法 如果l..i这一段已经有k种珍珠了. 那么就尝试把l++; (即把l这个影响尝试去掉一下 如果不足k种 ...

  9. Google笔试(2015年8月)

    华电北风吹 天津大学认知计算与应用重点实验室 日期:2015/8/21 这三道题目的PDF能够在这里下载 https://github.com/ncepuzhengyi/jobHuntingExam/ ...

  10. poj 2079 Triangle,旋转卡壳求点集的最大三角形

    给出一个点集,求顶点在点集中的最大的三角形面积. 我们知道这三角形的三个点肯定在凸包上,我们求出凸包之后不能枚举,由于题目n比較大,枚举的话要O(n^3)的数量级,所以採用旋转卡壳的做法: 首先枚举三 ...