問題一覧 > 通常問題

No.2358 xy+yz+zx=N

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 163
作問者 : 👑 qand / テスター : 👑 AngrySadEight ygussany
お気に入りにしたユーザー ProblemId : 9526 / 自分の提出
問題文最終更新日: 2023-06-23 23:37:58
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 394 (順位表) の他の問題:

Problem Statement

You are given a positive integer $N$.

Find all triples of non-negative integers $(x,y,z)$ satisfying $xy+yz+zx=N$.

Constraints

  • $1\le N\le 10^7$

Input

$N$

Output

Output in the following format.

$T$
$x_1$ $y_1$ $z_1$
$x_2$ $y_2$ $z_2$
$\vdots$
$x_T$ $y_T$ $z_T$
Here, $T$ must be the number of triples of non-negative integers satisfying the condition, and each $(x_i,y_i,z_i)$ must be a triple of non-negative integers satisfying the condition.

Also, $(x_i,y_i,z_i) \neq (x_j,y_j,z_j)$ must hold whenever $i\neq j$.

As long as the above conditions are satisfied, you may output the triples in any order.

Sample

Sample 1
Input
2
Output
6
0 1 2
0 2 1
1 0 2
1 2 0
2 0 1
2 1 0

The permutations of $(x,y,z)=(0,1,2)$ satisfy the condition.

This example outputs them in lexicographical order, but the output does not have to be in lexicographical order.

Sample 2
Input
5
Output
9
0 1 5
1 0 5
5 0 1
1 5 0
0 5 1
2 1 1
1 1 2
5 1 0
1 2 1

Sample 3
Input
97
Output
15
0 1 97
0 97 1
1 0 97
1 1 48
1 6 13
1 13 6
1 48 1
1 97 0
6 1 13
6 13 1
13 1 6
13 6 1
48 1 1
97 0 1
97 1 0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。