P17659 [IO 2025 #3] Fester's Great Theorem

Description

Wednesday Addams, a student of Nevermore Academy, is carrying out her gloomy experiments as usual. Recently, she found a strange formula in an old notebook of Uncle Fester: $a^n+b^n=c^n$. The formula looks suspiciously simple. Wednesday decided to check whether, for various $n$ and $c$, it has at least one solution in natural numbers. Let us assume that for $n>2$ there really are no solutions — Uncle Fester wrote a surprisingly simple proof in the margin next to the formula, and Wednesday is not going to argue with that. When $n=2$, the equation fills her with an irrational disgust, so she will not consider that case either. This leaves only non-negative $n

Input Format

The only line contains two space-separated integers $n$ and $c$ — the parameters of the equation in Uncle Fester's formula. Constraints: $0\le n\le1$, $-10^9\le c\le10^9$.

Output Format

If there exist integers $a,b\in[-10^9,10^9]$ such that $a^n+b^n=c^n$ holds, print `YES` on the first line, and print the space-separated integers $a$ and $b$ on the second line. If there is no solution, print a single line `NO`. Note: even if $a,b$ satisfy the equation, they will not be accepted unless $|a|,|b|\le10^9$.

Explanation/Hint

Translated by QwenWork