A. Ancient Civilization
好像就是对每个二进制位看一下0多还是1多,选择多的那个数就好了。
vp的时候直接猜的,交了一发直接过了
void solve(){
int n=read(),m=read();
vector<int>cnt0(m+1),cnt1(m+1);
for(int i=1;i<=n;i++){
int x=read();
for(int j=m;j>=1;j--){
if(x%2)cnt1[j]++;
else cnt0[j]++;
x/=2;
}
}
int ans=0;
for(int j=1;j<=m;j++){
if(cnt1[j]>cnt0[j])ans=ans*2+1;
else ans*=2;
}
cout<<ans<<'\n';
//puts(ans>0?"YES":"NO");
//puts(ans>0?"Yes":"No");
}
B. Elementary Particles
C. Road Optimization
D. Binary Spiders
E1. Cats on the Upgrade (easy version)
E2. Cats on the Upgrade (hard version)
标签:int,Codeforces,765,Cats,cnt1,ans,Div From: https://www.cnblogs.com/edgrass/p/17633935.html