fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. long long n;
  6. cin >> n;
  7. long long arr[n];
  8. for(int x=0;x<n;x++){
  9. cin >> arr[x];
  10. }
  11. sort(arr,arr+n);
  12. for(int i=n-1;i>=0;i--){
  13.  
  14. if((arr[n-1]%arr[i]!=0&&i<n-1)||arr[i]==arr[i-1]&&i>=1)
  15.  
  16.  
  17. { cout << arr[n-1] << " " << arr[i]<<endl;
  18. break;}}
  19. return 0;
  20. }
Success #stdin #stdout 0s 4380KB
stdin
4
1992 1991 1 1
stdout
1992 1991