Genius’s Gambit
题意:由a个0和b个1组成的二进制数(不含前导0)x和y使得x-y的二进制数恰好有k个1
思路:当 k<=a时比较好考虑 即 1000和 0001 类似这种,最多的1的个数为0的个数 ,当 k<=a+b-2 考虑 1111000-1011001=011111 最多可以有a+b-2个1。
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int inf=2e18+100;
const int maxn=2e5+100;
signed main()
{
int a,b,k;
cin>>a>>b>>k;
if((b==1||a==0)&&k==0)
{
cout<<"Yes"<<"\n";
for(int i=1; i<=b; i++)cout<<"1";
for(int i=1; i<=a; i++)cout<<"0";
cout<<"\n";
for(int i=1; i<=b; i++)cout<<"1";
for(int i=1; i<=a; i++)cout<<"0";
cout<<"\n";
}
else if(k<=a&&b>1)
{
cout<<"Yes"<<"\n";
for(int i=1; i<=b; i++)cout<<"1";
for(int i=1; i<=a; i++)cout<<"0";
cout<<"\n";
for(int i=1; i<b; i++)cout<<"1";
for(int i=1; i<=k; i++)cout<<"0";
cout<<"1";
for(int i=1; i<=a-k; i++)cout<<"0";
cout<<"\n";
}
else if(a!=0&&k<=a+b-2&&b>1)
{
cout<<"Yes"<<"\n";
for(int i=1; i<=b; i++)cout<<"1";
for(int i=1; i<=a; i++)cout<<"0";
cout<<"\n";
for(int i=1;i<=a+b-k-1;i++)cout<<"1";
cout<<"0";
for(int i=1;i<=k-a;i++)cout<<"1";
for(int i=1;i<=a-1;i++)cout<<"0";
cout<<"1";
cout<<"\n";
}
else cout<<"No"<<"\n";
}