time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputRecently you have received two positive integer numbers d in the list.
For example, if [1,6,3,2,4,1,2].
Your problem is to restore suitable positive integer numbers y 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 y.
Input
The first line contains one integer y.
The second line of the input contains y then there are two copies of this number in the list.
Output
Print two positive integer numbers y — such numbers that merged list of their divisors is the permutation of the given list of integers. It is guaranteed that the answer exists.
Example
input
Copy
10 10 2 8 1 2 4 1 20 4 5
output
Copy
20 8
#include<iostream> #include<algorithm> using namespace std; #define ll long long int a[10005],b[10005]; int main() { int n,j=0; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n); cout<<a[n-1]<<" "; for(int i=1;i<=a[n-1];i++) { if(a[n-1]%i==0) { b[j]=i; j++; } } for(int k=0;k<j;k++) { for(int i=0;i<n;i++) { if(a[i]==b[k]) { a[i]=1; break; } } } sort(a,a+n); cout<<a[n-1]<<endl; return 0; }