跳到正文

题解

题解:P11485 「Cfz Round 5」Non-breath Oblige

mine_mine约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年12月23日
收录
2026年3月22日
更新
2026年11月17日
篇幅
约 1 分钟
题目
P11485

版本

  1. v2当前
  2. v1

P11485 「Cfz Round 5」Non-breath Oblige 题解

题目传送门

题意

题目描述清晰,不多讲述。

结论

∀s=t\forall s=t,都有 ans=0ans=0。 ∀s,t∈[0,2n)\forall s,t \in [0,2^n) 且 s≠ts \ne t,都有 ans=(s⊕(2n−1))+(t⊕(2n−1))ans=(s\oplus(2^n-1))+(t\oplus(2^n-1)),其中 ansans 为最终的代价。

证明

若 s=ts = t,那么答案为 00。 若 s≠ts\ne t,如果我们要使 s⊕xs\oplus x 以及 t⊕xt \oplus x 的代价最小,那么我们将 ss 变成 2n−12^n-1,再将 2n−12^n-1 变成 tt 所需要的代价一定严格不大于其它 xx 所花费的代价。

code
C++
#include<bits/stdc++.h>
using namespace std;
signed main(){
	int T,n,s,t;
	for(cin>>T;T--;){
		cin>>n>>s>>t;
		if(s==t)puts("0");
		else cout<<((1<<n)-1^s)+((1<<n)-1^t)<<'\n';
	}
}
原文