| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 151308 | 陈棋 | 字符串的奇偶性 | C++ | Accepted | 1 MS | 268 KB | 389 | 2026-04-11 16:44:42 |
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin>>s){ if(s=="#") break; char req = s.back(); string bit=s.substr(0,s.size() - 1); int cnt=0; for(char c:bit){ if(c=='1') cnt++; } char add; if(req=='e'){ add=(cnt%2==0) ? '0' : '1'; } else{ add=(cnt%2==1) ? '0' : '1'; } cout<<bit+add<<endl; } return 0; }