結果

問題 No.2479 Sum of Squares
ユーザー e4q2pfnqe4q2pfnq
提出日時 2023-09-22 22:53:53
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 501 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 79,700 KB
最終ジャッジ日時 2023-09-22 22:53:57
合計ジャッジ時間 4,189 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,656 KB
testcase_01 AC 74 ms
71,432 KB
testcase_02 AC 73 ms
71,688 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 71 ms
71,484 KB
testcase_06 AC 74 ms
71,860 KB
testcase_07 AC 73 ms
71,840 KB
testcase_08 AC 73 ms
71,488 KB
testcase_09 AC 71 ms
71,904 KB
testcase_10 AC 71 ms
71,916 KB
testcase_11 AC 72 ms
71,720 KB
testcase_12 AC 71 ms
71,680 KB
testcase_13 AC 71 ms
71,920 KB
testcase_14 AC 75 ms
71,804 KB
testcase_15 AC 71 ms
71,856 KB
testcase_16 AC 71 ms
71,816 KB
testcase_17 AC 72 ms
71,928 KB
testcase_18 AC 71 ms
71,936 KB
testcase_19 AC 69 ms
71,680 KB
testcase_20 AC 70 ms
71,696 KB
testcase_21 AC 69 ms
71,680 KB
testcase_22 AC 71 ms
71,708 KB
testcase_23 AC 70 ms
71,976 KB
testcase_24 AC 70 ms
71,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import floor

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 = floor(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(a-3, 0, -3):
                T.append(j*j)
                f(X - j*j)
                T.pop()
        T.pop()
    
f(S)
0