zoukankan      html  css  js  c++  java
  • POJ 3863 Business Center

    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

     
    解题:直接搞呗。。貌似要求必须至少上一次
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long LL;
     4 LL n,m,u,d,ret;
     5 void check() {
     6     LL tmp = (n*d+u+d)/(u+d);
     7     ret = min(ret,(u+d)*tmp - n*d);
     8 }
     9 int main() {
    10     ios::sync_with_stdio(false);
    11     cin>>n>>m;
    12     ret = INT_MAX;
    13     while(m--) {
    14         cin>>u>>d;
    15         check();
    16     }
    17     cout<<ret<<endl;
    18     return 0;
    19 }
    View Code
  • 相关阅读:
    MOSS 之 自定义MembershipProvider实现Forms方式验证——学习实战篇
    (转)jquery.validate全攻略
    LinQ To Entity的增删改查(转)
    如何将程序集(.dll文件)添加到GAC(全局程序集缓存)?
    CSS Sprites (转)
    如何查看MOSS未知错误?
    用.Net开发Windows服务初探(转)
    早该知道的7个JavaScript技巧(转)
    最容易犯的13个JavaScript错误——转
    jQuery插件开发全解析(转)
  • 原文地址:https://www.cnblogs.com/crackpotisback/p/4624109.html
Copyright © 2011-2022 走看看