Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- FILE *fin, *fout;
- fin = fopen("suprapuneri.in", "r");
- fout = fopen("suprapuneri.out", "w");
- long long m, n, aux;
- int mBits, nBits, i, j, maxBits, ans, bitM, bitN;
- fscanf(fin, "%lld%lld", &m, &n);
- mBits = 0;
- aux = m;
- while (aux > 0) {
- aux >>= 1;
- ++mBits;
- }
- nBits = 0;
- aux = n;
- while (aux > 0) {
- aux >>= 1;
- ++nBits;
- }
- maxBits = max(mBits, nBits);
- ans = 0;
- for (i = 0; i <= maxBits; ++i) {
- j = 0;
- bitM = bitN = 0;
- while (j < maxBits && bitM == bitN) {
- bitM = (m & (1LL << ((i + j) % maxBits))) > 0;
- bitN = (n & (1LL << j)) > 0;
- ++j;
- }
- if (j == maxBits)
- ++ans;
- }
- fprintf(fout, "%d\n", ans);
- fclose(fin);
- fclose(fout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement