F - "Money, Money, Money"
Time Limit:
2000/1000MS (Java/Others)
Memory Limit:
128000/64000KB (Java/Others)
Special Judge
Problem 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.
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 ≤ 10
12).
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
3 4 5
Sample Output
2 5 0 0 3 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; }