#55199: cpp_answer


yp11451202@yphs.tp.edu.tw (705-38黃鈺潤)


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    long long I;
    
    // 持續讀取輸入,直到讀到 0 為止
    while (cin >> I && I != 0) {
        string binary = "";
        int count = 0;
        long long temp = I;
        
        // 進行進位轉換
        while (temp > 0) {
            int remainder = temp % 2;
            binary += to_string(remainder);
            if (remainder == 1) {
                count++; // 累加 1 的個數
            }
            temp /= 2;
        }
        
        // 因為是取餘數法,得到的字串是反過來的,需要翻轉
        reverse(binary.begin(), binary.end());
        
        // 按照題目要求的格式輸出
        cout << "The parity of " << binary << " is " << count << " (mod 2)." << endl;
    }
    
    return 0;
}