POJ 3863 Business Center

來源:互聯網
上載者:User

標籤:

Business CenterTime Limit: 1000msMemory Limit: 65536KBThis 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? InputThe 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). OutputWrite 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 315 1215 47 12
Sample Output
13
SourceNortheastern Europe 2009 解題:直接搞唄。。貌似要求必須至少上一次
 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

 

POJ 3863 Business Center

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.