Andrew Stankevich & #39; s Contest (21)
F-"Money, Money, Money"Time Limit:2000/1000 MS (Java/Others)Memory Limit:128000/64000 KB (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 extends ucted 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 file contains one number x (1 ≤ x ≤1012 ). 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
It is easy to know that any natural number can be expressed in the form of (2 * x + ODD). Therefore, for any odd number z, we can always find two numbers a, B, make it possible to construct all numbers greater than z; // for an even number, it cannot be constructed. (we hope the Giants can prove it)
AC code:
/** this code is made by eagle* Problem: 1408* Verdict: Accepted* Submission Date: 2014-10-03 07:05:36* Time: 0MS* Memory: 1676KB*/#include
using namespace std;typedef long long ll; int main(){ ll a; while(cin>>a){ if(a & 1){ cout<<2<<" "<