QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#11093. 简单方程

统计

给定一个大于 1 的整数 $k$,可以证明存在无穷多个正整数三元组 $(a, b, c)$ 满足以下方程: $$a^2 + b^2 + c^2 = k(ab + bc + ca) + 1$$

给定正整数 $n$ 和 $k$,请找到 $n$ 个满足该方程的任意三元组 $(a_1, b_1, c_1), (a_2, b_2, c_2), \dots, (a_n, b_n, c_n)$。此外,所有的 $3n$ 个整数 $a_1, \dots, a_n, b_1, \dots, b_n, c_1, \dots, c_n$ 必须是互不相同的正整数,且每个数最多包含 100 位十进制数字。

输入格式

第一行包含两个整数 $k$ 和 $n$ ($2 \le k \le 1000, 1 \le n \le 1000$),分别表示方程中的常数 $k$ 和需要寻找的三元组数量。

输出格式

输出 $n$ 行。第 $i$ 行应包含三个用空格分隔的整数 $a_i, b_i$ 和 $c_i$,且每个数最多包含 100 位数字,即你找到的第 $i$ 个解。

样例

输入 1

2 8

输出 1

1 2 6
3 10 24
12 35 88
15 28 84
4 5 18
14 33 90
40 104 273
21 60 152

输入 2

3 3

输出 2

1 3 12
8 21 87
44 165 615

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.