結果

問題 No.2479 Sum of Squares
ユーザー e4q2pfnqe4q2pfnq
提出日時 2023-09-22 22:43:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 471 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,488 KB
実行使用メモリ 79,228 KB
最終ジャッジ日時 2023-09-22 22:43:36
合計ジャッジ時間 3,839 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,208 KB
testcase_01 AC 68 ms
71,568 KB
testcase_02 AC 70 ms
71,412 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 71 ms
71,456 KB
testcase_06 AC 70 ms
71,572 KB
testcase_07 AC 73 ms
71,240 KB
testcase_08 AC 70 ms
71,480 KB
testcase_09 AC 70 ms
71,260 KB
testcase_10 AC 71 ms
71,512 KB
testcase_11 AC 70 ms
71,508 KB
testcase_12 AC 70 ms
71,412 KB
testcase_13 AC 82 ms
71,276 KB
testcase_14 AC 70 ms
71,452 KB
testcase_15 AC 71 ms
71,612 KB
testcase_16 AC 70 ms
71,076 KB
testcase_17 AC 72 ms
71,508 KB
testcase_18 AC 71 ms
71,308 KB
testcase_19 AC 69 ms
71,304 KB
testcase_20 AC 69 ms
71,068 KB
testcase_21 AC 70 ms
71,500 KB
testcase_22 AC 68 ms
71,256 KB
testcase_23 AC 70 ms
71,236 KB
testcase_24 AC 71 ms
71,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**9)

S = int(input())

T = []
def f(X):
    if X == 0 and len(T) <= 15:
        print(len(T))
        print(*T)
        exit()
    
    if len(T) > 15:
        return False
    
    a = int(X**0.5)
    for i in range(a, 0, -1):
        T.append(i*i)
        if f(X - i*i):
            T.pop()
            for j in range(1, a+1):
                T.append(j*j)
                f(X - j*j)
                T.pop()
        T.pop()
    
f(S)
0