Need some help:

guys ,can anyone tell me why i got tle ?
question:CodeChef: Practical coding for everyone
my solution:CodeChef: Practical coding for everyone

1 << i is an expression that returns integer. Since N \leq 10^{18} you’ll need to use long longs, so remember to use 1LL << i to produce long long answer. It’s a simple mistake, yet a very common one. :slight_smile:

1 Like

thx a lot bro :frowning_face_with_open_mouth:, but I did not understand what is conection b/w tle and this :woozy_face:

Think of it this way. You won’t stop until 1 << i exceeds N. Since 1 << i produces integers it is in range [-2 \cdot 10^9, 2 \cdot 10^9], while N is in range [0, 10^{18}]. So you see an issue with this - 1 << i can never reach values greater than [2 \cdot 10^9] while N can go up to 10^{18}. This issue is fixed by using 1LL << i as it covers much greater range. Hope it helps. :slight_smile:

1 Like

Basically 1LL is 1 in long long int format whereas 1 is in int format , so int format causes overflow whereas 1LL doesn’t.

1 Like