题解:P17659 [IO 2025 #3] 费斯特大定理

· · 题解

P17659 [IO 2025 #3] 费斯特大定理

题意简述

给定 n,c。求出满足 a^n+b^n=c^n 的一组 a,b\in[-10^9,10^9],保证 0\leq{}n\leq{}1。

分析

我们注意到:

运用上述分析编程即可。

代码如下:

#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;
}