fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int t, n;
  9. long long temp;
  10. vector<long long> factors;
  11. cin >> t;
  12. while(t--) {
  13. cin >> n;
  14. while(n--) {
  15. cin >> temp;
  16. factors.push_back(temp);
  17. }
  18. for(long long x = 0; x < 32769; x++) {
  19. long long sum = 0;
  20. long long copyX = 1;
  21. for(long long factor : factors) {
  22. sum += copyX*factor % 32768;
  23. copyX = copyX * x % 32768;
  24. }
  25. if (sum == 0) {
  26. cout << x << endl;
  27. break;
  28. }
  29. }
  30. }
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 4544KB
stdin
2
1
2 1
2
-40 3 1
stdout
Standard output is empty