fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. int32_t main(){
  7. int t;
  8. cin >> t;
  9. while(t){
  10. int n;
  11. cin >> n;
  12. int min_square = LLONG_MAX;
  13. for(int i = 1; i <= sqrt(n); i++){
  14. if(n % i == 0){
  15. int a = i, b = n / i;
  16. long double x = ((a - b) * (a - b)) / 4.0;
  17. if(x == floor(x) && (int)x < min_square){
  18. min_square = (int)x;
  19. }
  20. }
  21. }
  22. if(min_square == LLONG_MAX or min_square == 0){
  23. cout << -1 << endl;
  24. }
  25. else{
  26. cout << min_square << endl;
  27. }
  28. t--;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 4344KB
stdin
1
3
stdout
1