AcWing 3599. 奇偶校验
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e6+10;
int t,n,m,k,l,r,op,x,y;
int f[N];
bool flag;
void solve(){
string s,s2;
int onum = 0;
cin>>s;
for(char&ch:s){
s2 = string(7,'0');
m = 7-1;
x = (int)ch;
onum = 0;
while(x){
if(x%2){
onum++;
s2[m]++;
}
x/=2;
m--;
}
s2.insert(s2.begin(),onum%2?'0':'1');
cout<<s2<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}