2010年8月21日 星期六

10931 - Parity

定義整數 n 的parity為其二進制中各位元的總合取2的模數,例如,21(10進制) = 10101(2進制)共有3個1,故parity為 3 (mod 2) = 1。

本題要求你計算一整數 I 的 parity。 1 ≤ I ≤ 2147483647

Input

每一列有一個整數 I,最後一列 I=0 表示檔案結束,且不必輸出該列。

Output

請輸出 The parity of B is P (mod 2),其中B為 I 的二進制表示,P為parity。

Sample Input

1
2
10
21
0

Sample Output

The parity of 1 is 1 (mod 2).
The parity of 10 is 1 (mod 2).
The parity of 1010 is 2 (mod 2).
The parity of 10101 is 3 (mod 2).

原文出處

沒有留言:

張貼留言