Andrew Stankevich's Contest (21),stankevichcontest

來源:互聯網
上載者:User

Andrew Stankevich's Contest (21),stankevichcontest
F - "Money, Money, Money"Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)     Special JudgeSubmitStatusProblem Description      The government of Flatland has decided to carry out the money system reform. The purpose of the reform is to reduce the number of different banknotes denominations down to two. After the reform there will be two types of banknotes — a tupiks and b tupiks.
      The problem is that the president of Flatland doesn’t like the number x. Therefore the minister of finances was instructed to choose such a and b that it is impossible to pay exactly x tupiks without change. On the other hand it must be possible to pay all amounts larger than x.
      Now you are asked to help him — choose such a and b, or recommend the minister to retire, if it is impossible.Input      Input file contains one number x (1 ≤ x ≤ 1012).Output      Output two integer numbers a and b, such that it is impossible to pay x tupiks using banknotes of a and b tupiks without change, but it is possible to pay any larger sum. If it is impossible, output two zeroes to the output file.Sample Input

345
Sample Output
2 50 03 4
意解:易知任何一個自然數總可以表達成(2 * x + 奇數)的形式,所以對於任何的奇數z,總是可以找出兩個數a,b,使之可以構造出所有大於z的數; //而對於偶數,一定不可以構成;(希望巨巨們可以給出證明)

AC代碼:
/** this code is made by eagle* Problem: 1408* Verdict: Accepted* Submission Date: 2014-10-03 07:05:36* Time: 0MS* Memory: 1676KB*/#include <iostream> using namespace  std;typedef long long ll; int main(){       ll a;       while(cin>>a){           if(a & 1){               cout<<2<<" "<<a + 2<<endl;         }          else cout<<0<<" "<<0<<endl;       }   return 0;}





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.