a132. 10931 - Parity
Tags : Parity 進制轉換
Accepted rate: 4257人/ 4414人 ( 96%) [非即時]
評分方式:
Tolerant

最近更新 : 2011-05-25 18:04

Content

整數 n 的「同位元」定義為:其二進位表示法中每位元的和再除以 2 的餘數。例如:21 = 101012 的二進位有三個 1,因此它的同位元為 3 (mod 2),或 1。

在此,你要計算一個整數 1 ≤ I ≤ 2147483647 的同位元。

Input
輸入的每一行有一個整數 I,而 I = 0 表示輸入結束,該行無需處理。
Output
對於輸入中的每個整 I,你要印一行 The parity of B is P (mod 2).,其中 B 是 I 的二進位表示法。
Sample Input #1
1
2
10
21
0
Sample Output #1
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).
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (100%): 1.0s , <1M
Hint :
Tags:
Parity 進制轉換
出處:
UVa 10931 [管理者: snail (蝸牛) ]

Status Forum 排行

ID User Problem Subject Hit Post Date
53830 capa20031016 ... (Capa) a132
5440 2025-10-08 17:17
44379 1121228@stu. ... (你知道我是誰嗎!!??) a132
1985 2024-12-01 11:33
45991 1121226@stu. ... (Arthur✨EC) a132
356 2025-05-07 15:58
45009 caspar920216 ... (陳柏宇) a132
933 2025-01-01 22:24
40988 joccc014@gma ... (czone) a132
Python 解
787 2024-06-22 18:44