↵
I am working on 484A — Bits which should be an easy one. Unfortunately, I am facing a very strange thing that I have never seen before. Hope that someone can help me with it.↵
↵
Below is my code, and the problem is this code gives WA on test 2, line 12th, when the statement a = 0 is after cin >> l >> r, but when I just put the statement a = 0 before cin >> l >> r, it gives WA on test 2, line 11th. However, in both cases, I test on my computer, both code are correct.↵
↵
↵
↵
~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
#define len(u) (64
↵
int n;↵
int64_t l, r, a, u;↵
↵
int main(){↵
cin >> n;↵
while(n--){↵
cin >> l >> r;↵
a = 0;
while(len(l) == len(r) && r > 0){↵
u = 1 << (len(r)
l-= u, r-= u, a+= u;↵
}↵
u = 1 << (len(r)
u <<= (u + u
cout << a+u-1 << "\n";↵
}↵
return 0;↵
}↵
↵
~~~~~↵
↵
↵
↵
Thank you.