Can't figure out the WA on test #3. Please, help

Posted by

Nouaili 10 May 2021 17:44

I checked the output of my code for all K ( 1 <= k <= 65535), I think it gives the correct output.

https://github.com/Mourad-NOUAILI/Timus-Online-Judge/blob/main/1209/WA%233

long long type is used.

Code explanation:

I use a(k) = 1, 2, 2, 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 64, 64,... to compute a(k)

https://oeis.org/search?q=1%2C2%2C2%2C4%2C4%2C4%2C8%2C8%2C8%2C8%2C16%2C16%2C16%2C16%2C16&sort=&language=english&go=Search

the pos(k) in a(k) from 0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6, 5, 4, 3, 2, 1,..

https://oeis.org/search?q=1+0+2+1+0+3+2+1+0+4+3+2+1+0&sort=&language=english&go=Search

sequences are 0-base indexing.

example:

k = 16 --> a(15) = 32 = (100000)2

pos(15) in 0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4,... is 5, which means we gonna pick the bit at the 5th position from the left in 100000

100000

543210

so, for k = 16, the answer is 1

Thanks.