結果

問題 No.2479 Sum of Squares
ユーザー MottchanMottchan
提出日時 2023-09-22 22:57:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 2,516 ms
コンパイル使用メモリ 85,980 KB
実行使用メモリ 71,076 KB
最終ジャッジ日時 2023-09-22 22:57:13
合計ジャッジ時間 5,391 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,036 KB
testcase_01 AC 77 ms
70,948 KB
testcase_02 AC 76 ms
71,060 KB
testcase_03 AC 78 ms
70,984 KB
testcase_04 AC 78 ms
71,044 KB
testcase_05 AC 78 ms
71,020 KB
testcase_06 AC 78 ms
70,820 KB
testcase_07 AC 110 ms
70,640 KB
testcase_08 AC 79 ms
70,980 KB
testcase_09 AC 79 ms
70,896 KB
testcase_10 AC 81 ms
70,724 KB
testcase_11 AC 86 ms
70,640 KB
testcase_12 AC 76 ms
71,068 KB
testcase_13 AC 81 ms
71,076 KB
testcase_14 AC 71 ms
70,980 KB
testcase_15 AC 72 ms
71,028 KB
testcase_16 AC 75 ms
71,060 KB
testcase_17 AC 71 ms
70,720 KB
testcase_18 AC 71 ms
71,072 KB
testcase_19 AC 73 ms
70,900 KB
testcase_20 AC 75 ms
70,852 KB
testcase_21 AC 74 ms
70,968 KB
testcase_22 AC 73 ms
70,900 KB
testcase_23 AC 74 ms
70,992 KB
testcase_24 AC 72 ms
70,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ans=[]

def judge(x):
    if x**2 <= n:
        return 1
    else:
        return 0

while n > 1:   
    ok=0
    ng=10**18
    while ng-ok > 1:
        mid = (ng+ok)//2
        if judge(mid):
            ok = mid
        else:
            ng = mid
    #print(ok)
    ans.append(ok**2)
    n = n - ok**2

if n % 2 :
    ans.append(1)
    print(len(ans))
    print(*ans)
else:
    print(len(ans))
    print(*ans)
0