MATDYS - Editorial::whats wrong with my code?

,

https://www.codechef.com/viewsolution/15136273

i am having problem with subtask 3!

1 Like

A silly mistake!! You should typecast the pow function to unsigned long long too!! I made the exact same mistake a few days ago in Codeforces Round and choked as my answer failed on System Testing :stuck_out_tongue:

Your code after correction : link .

P.S. : I checked by submitting correct version of your code. Sorry for that but my intention was to check whether I am fully correct or not!!

A little suggestion for you .
Instead for storing the binary number in an array , you can initialize answer variable to 0 , do left shift by 1 and then add the remainder of the number k divide by 2 , divide k by 2 , decrement n by 1 and repeat this process until n>0 all the while using unsigned long long int . You are complicating the code too much for errors to creep in .
Here is my solution : https://www.codechef.com/viewsolution/15129361

Ouch! System tests are savage :frowning:

and how does that work?

Lol yea!! It was my fastest ever submission for a ‘B’ problem! I was in the air until the jury dragged me down lol xD

Damn!! Thanks for awarding points @mahendra25 :slight_smile: