题解:P17659 [IO 2025 #3] 费斯特大定理
P17659 [IO 2025 #3] 费斯特大定理
题意简述
给定
分析
我们注意到:
-
当
n=0 时,对于任意非零整数x ,x_n=1 。若a 与b 中不存在0 ,等式等价为1+1=1 ,显然不成立。又因为题目中说明了,若等式中有0^0 则认定等式不成立,所以当n=0 时等式不成立。 -
当
n=1 时,等式等价为a+b=c 。不难发现当a=\lfloor{}\frac{c}{2}\rfloor{} 且b=c-\lfloor{}\frac{c}{2}\rfloor{} 时等式成立。
运用上述分析编程即可。
代码如下:
#include<bits/stdc++.h>
using namespace std;
int n,c;
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr),cout.tie(nullptr);
cin>>n>>c;
if(n==1) cout<<"YES\n"<<(c>>1)<<' '<<(c-(c>>1));else cout<<"NO";
return 0;
}