ACM (UVa) : 10931


Data type:
Long Long Integer / Long Integer // depends

First we need to calculate the binary representation of Given Integer
We can do that easily by continuous Mod (%) and Divide (/) operation.
(see Project Euler: 4 >>> Filed under: Euler 1 to 10)
In C/C++, we can use function itoa under <stdlib.h>, but perhaps uva online judge don’t support this function, so it’s a better idea to convert it manually. Output should be exactly the same as given.

Critical input:


Critical output:
The parity of 1111111111111111111111111111111 is 31 (mod 2).
The parity of 11101110011010110010100000000 is 13 (mod 2).
The parity of 111011100110101100100111111111 is 21 (mod 2).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s