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. 理解 this.initialize.apply ( this, arguments )定义对象的一种方式

    var Class = { create:function() { return function() { this.initialize.apply(this, arguments); }; } } ...

  2. windows连接投影仪后桌面画面和白板画面不一致

    windows连接投影仪后桌面画面和白板画面不一致: 一. windows 搜索: 投影仪 选择相应的效果:

  3. RocketMQ学习笔记(9)----RocketMQ的Producer 顺序消息

    1. 顺序消息原理图 2. 什么是顺序消息? 消费消息的顺序要求同发送消息的顺序一致,在RocketMQ中,主要指的是局部顺序,即一类消息为满足顺序性,必须Producer单线程顺序发送,并且发送给到 ...

  4. 简洁的MVC思想框架——Nancy(环境配置与Get操作)

    Nancy官网——https://github.com/NancyFx/Nancy 概述:Nancy是一个开源的Web轻型框架内核符合MVC思想,有开发方便,路由简单的特点,而且功能齐全 起步:Hel ...

  5. WordPress 不错的插件

    Akismet – 防止垃圾评论 WP-PostViews Plus - 页面访问量统计 All in One SEO Pack – 搜索引擎优化的插件,自动优化搜索引擎. WP Super Cach ...

  6. LCT笔记

    先存个代码 #include<iostream> #include<cstring> #include<cstdio> #include<cmath> ...

  7. UI控件设置

    去掉cesium默认的版权信息: 在style样式中添加 .cesium-widget-credits {display:none !important} 去掉动画控件.地址搜索控件.图层选择控件.操 ...

  8. pandas 3 设置值

    from __future__ import print_function import pandas as pd import numpy as np np.random.seed(1) dates ...

  9. POJ 2828 Buy Tickets(线段树&#183;插队)

    题意  n个人排队  每一个人都有个属性值  依次输入n个pos[i]  val[i]  表示第i个人直接插到当前第pos[i]个人后面  他的属性值为val[i]  要求最后依次输出队中各个人的属性 ...

  10. GraphicsMagick java.io.FileNotFoundException: gm 错误解决办法

    GraphicsMagick java.io.FileNotFoundException: gm 解决办法, 方法一: ProcessStarter.setGlobalSearchPath(" ...