fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. int t,n,x,y; cin >> t;
  6. while(t--){
  7. cin >> n;
  8. multiset<int>s;
  9. bool found = false;
  10. for(int i=0;i<n;i++){
  11. cin >> x;
  12. s.insert(x);
  13. }
  14. if(s.size() == 3) cout << "1 1\n";
  15. else{
  16. for(auto it=s.begin();it!=s.end();++it){
  17. if(s.find((n-2) / *it) != s.end() && s.find((n-2) / *it) != it){
  18. cout << *it << " " << (n-2) / *it << endl;
  19. break;
  20. }
  21. }
  22. }
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 5280KB
stdin
5
3
1 1 2
11
3 3 4 5 6 7 8 9 9 10 11
8
8 4 8 3 8 2 8 1
6
2 1 4 5 3 3
8
1 2 6 3 8 5 5 3
stdout
1 1
3 3
2 3
1 4
1 6