2026牛客国庆集训派对day6
G
Pythagorathean Transformation
牛客竞赛
未评级
原题
← FH →

Pythagorathean Transformation官方中文

题目描述

官方中文

For a positive integer $s$, you can perform the following operation an arbitrary number of times (including zero): Choose a positive integer triplet $(a, b, c)$ such that $s \in \{a, b, c\}$, $a^2 + b^2 = c^2$. Choose a positive integer $t \in \{a, b, c\}\setminus \{s\}$,then replace $s$ with $t$. Given $S$ and $T$, you need to transform $S$ into $T$ within 2000 steps ensuring that the value of each number during the transformation does not exceed or determine that it is not possible.官方中文

输入格式

官方中文

The only line of input contains two integers $S,T$ $(1\leq S,T\leq 10^9, S\neq T)$.官方中文

输出格式

官方中文

If it is not possible to transform $S$ into $T$ within 2000 steps, output “impossible” in a line. The first line contains one integer $m$ $(1\leq m\leq 2000)$, denoting the number of steps. Then you need to output $m$ lines, with the $i$-th line containing a positive integer $x$ $(1\leq x\leq 10^{18})$, representing the result after the $i$-th operation.官方中文

样例

Input #1
3 5
Output #1
1
5
Input #2
4 12
Output #2
2
5
12
Input #3
1 100
Output #3
impossible
题目信息
题号
nc140734pg
时间限制
1 s
内存限制
1024 MB

题面与样例版权归 牛客竞赛 及出题人所有;中文翻译由 AI 生成(官方原文),如有出入请以原文为准。