HOW D

学术版

@[ETO_leader](/user/388691) D做法有人比我抽象吗/kx ```cpp #include<bits/stdc++.h> using namespace std; #define ll long long ll a,b,c; vector<bool> A,B; int popcount(ll x){ int ret=0; while(x){ ret+=(x&1); x>>=1; }return ret; } ll tonum(vector<bool> v){ reverse(v.begin(),v.end()); ll ret=0; for(auto x:v){ ret<<=1; ret|=x; } return ret; } void solve(int x){ if(x>a||x>b||x<0)cout<<"-1\n",exit(0); ll QAQ=a-x,QBQ=b-x,QCQ=c; //cout<<QCQ<<'\n'; for(int i=0;i<60;++i){ //cout<<(QCQ&1); if(QCQ&1){ //cout<<QAQ<<' '<<QBQ<<'\n'; if(QAQ)--QAQ,A[i]=1; else --QBQ,B[i]=1; } else{ if(x)A[i]=B[i]=1,--x; } QCQ>>=1; } } int main() { ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); cin>>a>>b>>c; A.resize(60),B.resize(60); if(popcount(c)>a+b||popcount(c)%2!=(a+b)%2)cout<<"-1\n",exit(0); solve((a+b-popcount(c))/2); if((tonum(A)^tonum(B))!=c||popcount(tonum(A))!=a||popcount(tonum(B))!=b||tonum(A)>=(1ll<<60)||tonum(B)>=(1ll<<60))cout<<"-1\n",exit(0); cout<<tonum(A)<<' '<<tonum(B); return 0; } ```
by digger @ 2024-03-30 21:55:18


@[digger](/user/705143) 有 https://www.luogu.com.cn/discuss/800098
by Konjac_C @ 2024-03-30 21:57:12


|