P11485题解
lihouze1019 · · 题解
思路 1.判断S是否等于T,如果相等,那么代价为0 2.将S变成2的n次方-1,判断此时是否等于T,如果相等,那么代价为(S^(2^n-1)) 3.将S'变成T,那么此时的代价为(S'^T)+(S^(2^n-1))
代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int T;
cin>>T;
for(int i=1;i<=T;i++){
long long n,s,t;
cin>>n>>s>>t;
long long pw=pow(2,n);
long long dj=0;
if(s==t){
cout<<0<<endl;
}else{
dj+=s^(pw-1);
s=pw-1;
if(s==t){
cout<<dj<<endl;
}else{
dj+=s^t;
s=t;
cout<<dj<<endl;
}
}
}
return 0;
}