Run ID:158675
提交时间:2026-08-22 16:31:24
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { if (s == "#") break; int cnt1 = 0; for (int i = 0; i < s.size() - 1; i++) { if (s[i] == '1') cnt1++; } char op = s.back(); char add; if (op == 'e') { if (cnt1 % 2 == 0) add = '0'; else add = '1'; } else { if (cnt1 % 2 == 1) add = '0'; else add = '1'; } string ans = s.substr(0, s.size()-1) + add; cout << ans << endl; } return 0; }