P17181 [ICPC 2017 Hong Kong R] Fermat's Optimization Problem
Description
Consider the error function $F(x, y, z, n) = |x^n + y^n - z^n|$, where $|v|$ means the absolute value of $v$. Given two positive integers $n$ and $z$, our problem is to find two positive integers $x$ and $y$ such that $x < y < z$ and the error value $F(x, y, z, n)$ is minimized. There may be multiple values of $x$ and $y$ that minimize $F(x, y, z, n)$, and you may output any of them.
For example, if we are given $n = 3$ and $z = 9$, then the solution is: $x = 6$ and $y = 8$. This solution yields the error value $1$.
Input Format
The first line contains the number of test cases $T$ ($T < 10$). Each subsequent line corresponds to a test case, which contains two positive integers $n$ ($2 < n < 10$) and $z$ ($1 < z < 100000$).
Output Format
For each test case, output the value of $x$, $y$, and $F(x, y, z, n)$ in a line, separated by spaces.