Run ID:160620

提交时间:2026-09-24 20:36:47

#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); string s; while (cin >> s) { if (s == "#") { break; } int len = s.length(); char parityType = s[len - 1]; int countOnes = 0; for (int i = 0; i < len - 1; ++i) { if (s[i] == '1') { countOnes++; } } char checkBit; if (parityType == 'e') { if (countOnes % 2 == 0) { checkBit = '0'; } else { checkBit = '1'; } } else { if (countOnes % 2 == 0) { checkBit = '1'; } else { checkBit = '0'; } } s[len - 1] = checkBit; cout << s << endl; } return 0; }