#P1011. Hack it!
Hack it!
题目描述
Please notice that this problem only needs you to give your hack data, which means you think Little m's program can't pass your input data.
Little m got a problem yesterday, which is below:
Recently you have received two positive integer numbers and . You forgot them, but you remembered a shuffled list containing all divisors of xx (including and ) and all divisors of (including and ). If is a divisor of both numbers and at the same time, there are two occurrences of in the list.
For example, if and then the given list can be any permutation of the list [1,2,4,1,2,3,6]. Some of the possible lists are: [1,1,2,4,6,3,2],[4,6,1,1,2,3,2] or [1,6,3,2,4,1,2].
Your problem is to restore suitable positive integer numbers and that would yield the same list of divisors (possibly in different order).
It is guaranteed that the answer exists, i.e. the given list of divisors corresponds to some positive integers and .
Input
The first line contains one integer — the number of divisors of and .
The second line of the input contains integers , where is either divisor of or divisor of . If a number is divisor of both numbers and then there are two copies of this number in the list.
Output
Print two positive integer numbers and — such numbers that merged list of their divisors is the permutation of the given list of integers. It is guaranteed that the answer exists, and you can print any order of x and y.
Sample Input and Output
Sample Input Sample Output 10
10 2 8 1 2 4 1 20 4 520 8
And he has got a solution which is below:
#include <iostream>
#include <algorithm>
int a[1005];
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
std::sort(a+1,a+1+n);
if(a[n]==a[n-1]) printf("%d %d",a[n],a[n]);
else
{
int x=a[n],y=0;
for(int j=n-1;j;j--)
if(x%a[j]!=0)
{
y=a[j];
break;
}
printf("%d %d",x,y);
}
}
And fortunately, he passed all the tests. But Mr.M found that there might be some problems in little m's code. He wants to point it out, but he is very busy to do that, so he asks you to hack his code.
To hack one's code is that you construct the input, then if the code gives wrong output, you hack the code successfully, otherwise, you fail to hack the code.
And you need to guarantee that your input is under the constraints of the original problem's input.
In this problem, if you hack the code successfully, you will get Accepted.
Otherwise, if your input is invalid or you fail to hack the code, you will both get WRONG ANSWER.
If there are multiple ways to hack the code, any one of them is accepted.
输入格式
输出格式
样例
10
10 2 8 1 2 4 1 20 4 5
the code will output 20 8 then you fail to hack the code, you will get WRONG_ANSWER
提示
We have one example in the sample input, please notice that it is not right.