fork(4) 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. n++;
  15. while(n--) {
  16. cin >> temp;
  17. factors.push_back(temp);
  18. }
  19. for(long long x = 0; x < 32769; x++) {
  20. long long sum = 0;
  21. long long copyX = 1;
  22. for(long long factor : factors) {
  23. sum += copyX*factor % 32768;
  24. copyX = copyX * x % 32768;
  25. }
  26. if (sum == 0) {
  27. cout << x << endl;
  28. break;
  29. }
  30. }
  31. }
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 4368KB
stdin
2
1
2 1
2
-40 3 1
stdout
Standard output is empty