No.2479 Sum of Squares
問題文最終更新日: 2023-09-22 17:32:27
English (AI translation)
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
Problem Statement
Given a positive integer $S$, find one sequence $A$ of positive integers of length at most $15$ that satisfies the following conditions.
- $A_i (1 \leq i \leq |A|)$ is a perfect square
- $\displaystyle \sum_{i=1}^{|A|} A_i=S$
Input
$S$
- $1 \leq S \leq 10^{18}$
- All inputs are integers
Output
Print the length of the sequence on the first line, and print the elements of the sequence on the second line, separated by spaces.
Sample
Sample 1
Input
14
Output
3 1 4 9
$14=1+4+9$, and $1,4,9$ are all perfect squares.
Sample 2
Input
43
Output
3 25 9 9
It can also be written as $43=25+16+1+1$. There may be multiple solutions.
Sample 3
Input
34764
Output
10 8100 4 3721 784 100 1225 8649 7056 900 4225
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
takumaiq
keisuke6