fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. int main(){
  6. int t; cin >> t;
  7. while(t--){
  8. int n,k,x; cin >> n;
  9. k = n - 2;
  10. int a[n];
  11. map<int,int>ch;
  12. for(int i=0;i<n;i++) cin >> a[i];
  13. for(int i=0;i<n;i++){
  14. x = a[i];
  15. if(k % x == 0){
  16. if(ch.find(k / x) != ch.end()){
  17. cout << x << " " << k / x << endl;
  18. break;
  19. }
  20. }
  21. ch[x]++;
  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
4 1
6 1