結果

問題 No.2479 Sum of Squares
コンテスト
ユーザー LyricalMaestro
提出日時 2026-07-26 13:48:52
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 65 ms / 2,000 ms
+ 131µs
コード長 571 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 458 ms
コンパイル使用メモリ 95,852 KB
実行使用メモリ 79,104 KB
最終ジャッジ日時 2026-07-26 13:49:44
合計ジャッジ時間 3,783 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/2479

import math

def sq(S):
    low = 0
    high = 2 * int(math.sqrt(S))
    while high - low > 1:
        mid = (high + low) // 2
        if mid ** 2 <= S:
            low = mid
        else:
            high = mid
    if high ** 2 <= S:
        return high
    else:
        return low


def main():
    S = int(input())

    array = []
    s = S
    while s > 0:
        s_ = sq(s)
        array.append(s_ ** 2)
        s -= s_ ** 2
    print(len(array))
    print(" ".join(map(str, array)))

if __name__ == '__main__':
    main()
0