fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int t;
  5. cin>>t;
  6. while(t--){
  7. long long n;
  8. cin>>n;
  9. long long x = n;
  10. bool flag = false;
  11. while(x--){
  12. long long ans = x^n;
  13. if(x+n>ans && x+ans>n && n+ans>x){
  14. flag = true;
  15. break;
  16. }
  17. }
  18. if(flag){
  19. cout<<x<<endl;
  20. }else{
  21. cout<<"-1"<<endl;
  22. }
  23. }
  24. }
Success #stdin #stdout 0.01s 5288KB
stdin
7
5
2
6
3
69
4
420
stdout
3
-1
5
-1
67
-1
419