#P1400. [CERC2016] Easy Equation

[CERC2016] Easy Equation

题目描述

Given an integer kk greater than 11, it is possible to prove that there are infinitely many triples of positive integers (a,b,c)(a, b, c) that satisfy the following equation:

a2+b2+c2=k(ab+bc+ca)+1a^2+b^2+c^2=k(ab+bc+ca)+1

Given positive integers nn and kk, find nn arbitrary triples $(a_1, b_1, c_1), (a_2, b_2, c_2), \cdots , (a_n, b_n, c_n)$ that all satisfy the equation. Furthermore, all 3n3n integers $(a_1, b_1, c_1), (a_2, b_2, c_2), \cdots , (a_n, b_n, c_n)$ should be different positive integers with at most 100100 decimal digits each.

输入格式

The first line contains two integers kk and n  (2k1000,1n1000)n\;(2 \leq k \leq 1000, 1 \leq n \leq 1000) — the constant k in the equation and the target number of triples.

输出格式

Output nn lines. The ii-th line should contain three space separated integers aia_i, bib_i and cic_i with at most 100100 digits each — the ii-th of the solutions you found.

题目大意

题目描述:

假设 kk 大于 11, 可以证明有无穷多个正整数三元组 (a,b,c)(a, b, c) 满足以下方程:

a2+b2+c2=k(ab+bc+ca)+1a^2 + b^2 + c^2 = k(ab + bc + ca) + 1

给定正整数 nnkk,找出 nn 个三元组 $(a_1, b_1, c_1), (a_2, b_2, c_2), ⋯ ,(a_n, b_n, c_n)$ 使它们都满足方程。另外,这 3n3n 个正整数 $(a_1, b_1, c_1), (a_2, b_2, c_2), ⋯ ,(a_n, b_n, c_n)$ 应该是不同的,每个数最多有 100100 位。

输入格式:

第一行包含两个整数: 方程中的常数 kk 和 所求三元组的数量 nn (2k1000,1n1000)(2 ≤ k ≤ 1000, 1 ≤ n ≤ 1000);

输出格式:

输出有 nn 行。第 ii 行应该包含三个空格分隔的正整数 aiai, bibicici, 为你找到的第 ii 个解。每个数最多 100100 位。

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