#P1400. Distinct Triple Construction for a Quadratic Diophantine Equation

    ID: 14686 Type: Default 1000ms 256MiB

Distinct Triple Construction for a Quadratic Diophantine Equation

Distinct Triple Construction for a Quadratic Diophantine Equation

Given an integer \(k\) greater than 1, it can be shown that there exist infinitely many triples of positive integers \((a,b,c)\) satisfying

\[ a^2+b^2+c^2 = k(ab+bc+ca)+1, \]

Given positive integers \(n\) and \(k\), you are asked to find any \(n\) triples \( (a_1,b_1,c_1), (a_2,b_2,c_2), \ldots, (a_n,b_n,c_n) \) that satisfy the equation. Moreover, all \(3n\) integers among these triples must be distinct and have at most 100 decimal digits.

Note: It is guaranteed that for any \(k>1\), infinitely many solutions exist. You only need to output arbitrary valid triples. In case there are multiple valid answers, any one is accepted.

inputFormat

The input consists of a single line containing two integers \(n\) and \(k\) \( (1 \le n \le 100,\; 2 \le k \le 10^5)\).

outputFormat

Output \(n\) lines. Each line should contain three space‐separated positive integers \(a, b, c\) which form a valid triple satisfying the equation \(a^2+b^2+c^2 = k(ab+ac+bc)+1\). All numbers in the output must be distinct and have at most 100 digits.

sample

1 2
1 2 6