結果

問題 No.2479 Sum of Squares
ユーザー 👑 KazunKazun
提出日時 2023-09-24 01:14:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 1,531 ms
コンパイル使用メモリ 86,688 KB
実行使用メモリ 71,776 KB
最終ジャッジ日時 2023-09-24 01:14:40
合計ジャッジ時間 4,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,604 KB
testcase_01 AC 73 ms
71,504 KB
testcase_02 AC 74 ms
71,420 KB
testcase_03 AC 74 ms
71,264 KB
testcase_04 AC 77 ms
71,620 KB
testcase_05 AC 77 ms
71,500 KB
testcase_06 AC 75 ms
71,488 KB
testcase_07 AC 75 ms
71,760 KB
testcase_08 AC 75 ms
71,288 KB
testcase_09 AC 76 ms
71,676 KB
testcase_10 AC 74 ms
71,672 KB
testcase_11 AC 74 ms
71,668 KB
testcase_12 AC 75 ms
71,496 KB
testcase_13 AC 75 ms
71,604 KB
testcase_14 AC 73 ms
71,604 KB
testcase_15 AC 76 ms
71,412 KB
testcase_16 AC 76 ms
71,492 KB
testcase_17 AC 73 ms
71,640 KB
testcase_18 AC 80 ms
71,516 KB
testcase_19 AC 76 ms
71,688 KB
testcase_20 AC 74 ms
71,688 KB
testcase_21 AC 77 ms
71,776 KB
testcase_22 AC 81 ms
71,744 KB
testcase_23 AC 76 ms
71,424 KB
testcase_24 AC 75 ms
71,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Floor_Root(a,k):
    """floor(a^(1/k)) を求める.

    a:非負整数
    k:正の整数
    """
    assert 0<=a and 0<k
    if a==0: return 0
    if k==1: return a

    #大体の値を求める.
    x=int(pow(a,1/k))

    #増やす
    while pow(x+1,k)<=a:
        x+=1

    #減らす
    while pow(x,k)>a:
        x-=1
    return x

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

    A = []
    while S:
        x = Floor_Root(S, 2)
        A.append(x * x)
        S -= x * x

    print(len(A))
    print(*A)

#==================================================
solve()
0