Advertisement
7oSkaaa

F - Batman Xor

Aug 13th, 2022
1,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define cin_2d(vec, n, m) for(int i = 0; i < n; i++) for(int j = 0; j < m && cin >> vec[i][j]; j++);
  6. #define cout_2d(vec, n, m) for(int i = 0; i < n; i++, cout << "\n") for(int j = 0; j < m && cout << vec[i][j] << " "; j++);
  7. #define fixed(n) fixed << setprecision(n)
  8. #define ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  9. #define fill(vec, value) memset(vec, value, sizeof(vec));
  10. #define mul_mod(a, b, m) (((a % m) * (b % m)) % m)
  11. #define add_mod(a, b, m) (((a % m) + (b % m)) % m)
  12. #define all(vec) vec.begin(), vec.end()
  13. #define rall(vec) vec.rbegin(), vec.rend()
  14. #define sz(x) int(x.size())
  15. #define debug(x) cout << #x << ": " << (x) << "\n";
  16. #define fi first
  17. #define se second
  18. #define ll long long
  19. #define ull unsigned long long
  20. #define Mod  1'000'000'007
  21. #define OO 2'000'000'000
  22. #define EPS 1e-9
  23. #define PI acos(-1)
  24. template < typename T = int > using Pair = pair < T, T >;
  25.  
  26. template < typename T = int > istream& operator >> (istream &in, vector < T > &v) {
  27.     for (auto &x : v) in >> x;
  28.     return in;
  29. }
  30.  
  31. template < typename T = int > ostream& operator << (ostream &out, const vector < T > &v) {
  32.     for (const T &x : v) out << x << ' ';
  33.     return out;
  34. }
  35.  
  36. void Fast_IO(){
  37.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  38.     #ifndef ONLINE_JUDGE
  39.         freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  40.     #endif
  41. }
  42.  
  43. constexpr ll MOD = 1e9 + 7;
  44.  
  45. void Solve(){
  46.     ll n;
  47.     cin >> n;
  48.     ll ans = 1;
  49.     if(n == 2)
  50.         return cout << 2 << '\n', void();
  51.     while(ans < n)
  52.         ans *= 2;
  53.     if(ans == n)
  54.         ans *= 2, ans--;
  55.     cout << ans % MOD << '\n';
  56. }
  57.  
  58. int main(){
  59.     Fast_IO();
  60.     int t = 1;
  61.     cin >> t;
  62.     while(t--)
  63.         Solve();
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement