题解:P11485 「Cfz Round 5」Non-breath Oblige
题目大意
给定
令
证明
s=t
无需任何操作,代价为
s \lor t = f
此时
s \lor t \neq f
此时
中间值选择依据:
第一步操作:将
第二步操作:将
总代价为两步之和
#include<bits/stdc++.h>
using namespace std;
int T;
int main()
{
cin>>T;
while(T--)
{
long long n,s,t;
cin>>n>>s>>t;
if(s==t)
{
cout<<0<<endl;
continue;
}
long long f=(1LL<<n)-1;
if((s|t)==f)
{
cout<<(long long)(s^t)<<endl;
}
else
{
long long c1=s^f,c2=f^t;
cout<<c1+c2<<endl;
}
}
return 0;
}