Advertisement
cosenza987

Untitled

Oct 11th, 2021
996
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. // Problem: F. Xorro the Xorman
  2. // Contest: Codeforces - UTPC Contest 10-23-20 Div. 2
  3. // Memory Limit: 256 MB
  4. // Time Limit: 1000 ms
  5. // Date / Time: 2021-10-04 19:35:06
  6. // Author: cosenza
  7. // всё что ни делается - всё к лучшему
  8. // check list -> long long, special cases, array size, mod (a*b%p*c%p not a*b*c%p  ,  (a-b+p)%p not a-b )
  9. //
  10. // Powered by CP Editor (https://cpeditor.org)
  11.  
  12. //#pragma GCC optimize("Ofast")
  13. //#pragma GCC optimize ("unroll-loops")
  14. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  15. //THESE ARE LAST DITCH EFFORTS!!!
  16.  
  17. #include <bits/stdc++.h>
  18.  
  19. using namespace std;
  20.  
  21. int main() {
  22.     ios_base::sync_with_stdio(false);
  23.     cin.tie(0);
  24.     long long a, b;
  25.     cin >> a >> b;
  26.     int b1 = 63 - __builtin_clzll(b);
  27.     bool pode = false;
  28.     for(int i = b1; i >= 0; i--) {
  29.         if((a & (1ll << i)) and (b & (1ll << i))) {
  30.             pode = true;
  31.         }
  32.         if(!(a & (1ll << i))) {
  33.             if(b & (1ll << i)) {
  34.                 a |= (1ll << i);
  35.             } else {
  36.                 if(pode) {
  37.                     a |= (1ll << i);
  38.                 }
  39.             }
  40.         }
  41.     }
  42.     cout << a << "\n";
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement