fork download
  1. #include <bits/stdc++.h>
  2. #define endl "\n"
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. ios::sync_with_stdio(false);
  8. cin.tie(0);
  9. long long int t;
  10. cin>>t;
  11. while (t--)
  12. {
  13. long long int x;
  14. cin>>x;
  15. if (x==1)
  16. cout<<1<<endl;
  17. else if (x==0)
  18. cout<<3<<endl;
  19. else
  20. {
  21. long long int temp = x%4;
  22. if (temp==0)
  23. cout<<x<<endl;
  24. else if (temp==1 || temp==2)
  25. cout<<"-1"<<endl;
  26. else
  27. cout<<x-1<<endl;
  28. }
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 3452KB
stdin
1
9
stdout
-1