結果

問題 No.2479 Sum of Squares
ユーザー Cecil
提出日時 2023-09-23 16:33:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-07-16 16:25:44
合計ジャッジ時間 1,973 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

from decimal import Decimal
import math
import bisect

def binary_search(num):
    l = 1
    r = 10**9+1
    mid = (l+r)//2
    while r-l > 1:
        mid = (l+r)//2
        if mid*mid <= num:
            l = mid
        else:
            r = mid
    return l
s = int(input())
ans = list()        
while True:
    if s == 0:
        break
    num = binary_search(s)
    ans.append(num*num)
    s -= num*num
print(len(ans))
print(*ans)
0