1790E: Vlad and a pair of Numbers (Doubt)

Правка en2, от ProveMeRight, 2023-06-11 08:51:12

209248600

...
int a = x;
int b = 0;

for(int i= 29;i>=0;i--)
    {
        if((x & (1 << i)) > 0)
        {
            continue;
        }

        if((2*x - a - b) >= (2 << i))
        {
            // bug(a,b);
            a += (1 << i);
            b += (1 << i);
        }
    }

When I am making the start from i= 30 or more, it makes a negative. Why?

Note: I defined int as long long. Still, It's doing the same.

Can anyone please explain?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский ProveMeRight 2023-06-11 08:51:12 15
en1 Английский ProveMeRight 2023-06-11 08:49:21 538 Initial revision (published)