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