QOJ.ac

QOJ

حد الوقت: 3.0 s حد الذاكرة: 256 MB مجموع النقاط: 100

#11774. 费马优化问题

الإحصائيات

考虑误差函数 $F(x, y, z, n) = |x^n + y^n - z^n|$,其中 $|v|$ 表示 $v$ 的绝对值。给定两个正整数 $n$ 和 $z$,我们的问题是找到两个正整数 $x$ 和 $y$,使得 $x < y < z$ 且误差值 $F(x, y, z, n)$ 最小。

例如,如果我们给定 $n = 3$ 且 $z = 9$,那么解为:$x = 6$ 和 $y = 8$。该解产生的误差值为 $1$。

输入格式

第一行包含测试用例的数量 $T$ ($T < 10$)。接下来的每一行对应一个测试用例,包含两个正整数 $n$ ($2 < n < 10$) 和 $z$ ($1 < z < 100000$)。

输出格式

对于每个测试用例,输出一行 $x$、$y$ 和 $F(x, y, z, n)$ 的值,中间用空格分隔。

样例

输入 1

2
3 9
3 7

输出 1

6 8 1
5 6 2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.