結果

問題 No.2479 Sum of Squares
ユーザー n_nan_na
提出日時 2023-09-23 00:21:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 660 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 72,180 KB
最終ジャッジ日時 2023-09-23 00:21:24
合計ジャッジ時間 4,115 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,564 KB
testcase_01 AC 72 ms
71,684 KB
testcase_02 AC 72 ms
71,760 KB
testcase_03 AC 70 ms
71,772 KB
testcase_04 AC 72 ms
71,976 KB
testcase_05 AC 76 ms
71,940 KB
testcase_06 AC 72 ms
71,864 KB
testcase_07 AC 73 ms
71,816 KB
testcase_08 AC 73 ms
71,860 KB
testcase_09 AC 72 ms
72,180 KB
testcase_10 AC 72 ms
71,956 KB
testcase_11 AC 71 ms
71,928 KB
testcase_12 AC 71 ms
71,816 KB
testcase_13 AC 71 ms
71,716 KB
testcase_14 AC 74 ms
71,584 KB
testcase_15 AC 72 ms
71,564 KB
testcase_16 AC 78 ms
71,864 KB
testcase_17 AC 72 ms
71,564 KB
testcase_18 AC 74 ms
71,544 KB
testcase_19 AC 74 ms
71,820 KB
testcase_20 AC 73 ms
71,860 KB
testcase_21 AC 72 ms
72,092 KB
testcase_22 AC 72 ms
71,832 KB
testcase_23 AC 73 ms
71,832 KB
testcase_24 AC 73 ms
72,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

S = int(input())

A = []
while S > 0:
    i = 0
    while True:
        k = int(math.floor(pow(S, 0.5))) - i
        if S - pow(k, 2) >= 0:
            break
        else:
            i += 1
    S -= pow(k,2)
    A.append(pow(k,2))
#    print(A,S,k,k**2)
    
print(len(A))
print(*A)
0