SHARE
TWEET

Untitled

a guest Jan 19th, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.   FILE *fin, *fout;
  6.   fin = fopen("suprapuneri.in", "r");
  7.   fout = fopen("suprapuneri.out", "w");
  8.  
  9.   long long m, n, aux;
  10.   int mBits, nBits, i, j, maxBits, ans, bitM, bitN;
  11.   fscanf(fin, "%lld%lld", &m, &n);
  12.  
  13.   mBits = 0;
  14.   aux = m;
  15.   while (aux > 0) {
  16.     aux >>= 1;
  17.     ++mBits;
  18.   }
  19.  
  20.   nBits = 0;
  21.   aux = n;
  22.   while (aux > 0) {
  23.     aux >>= 1;
  24.     ++nBits;
  25.   }
  26.  
  27.   maxBits = max(mBits, nBits);
  28.  
  29.   ans = 0;
  30.   for (i = 0; i <= maxBits; ++i) {
  31.     j = 0;
  32.     bitM = bitN = 0;
  33.  
  34.     while (j < maxBits && bitM == bitN) {
  35.       bitM = (m & (1LL << ((i + j) % maxBits))) > 0;
  36.       bitN = (n & (1LL << j)) > 0;
  37.       ++j;
  38.     }
  39.  
  40.     if (j == maxBits)
  41.       ++ans;
  42.   }
  43.  
  44.   fprintf(fout, "%d\n", ans);
  45.  
  46.   fclose(fin);
  47.   fclose(fout);
  48.   return 0;
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top