結果

問題 No.800 四平方定理
ユーザー 👑 H20H20
提出日時 2020-11-19 09:46:34
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 546 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 101,164 KB
最終ジャッジ日時 2023-09-30 15:44:58
合計ジャッジ時間 6,494 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
93,532 KB
testcase_01 AC 216 ms
96,660 KB
testcase_02 AC 185 ms
90,268 KB
testcase_03 AC 192 ms
92,084 KB
testcase_04 AC 182 ms
88,964 KB
testcase_05 AC 193 ms
91,456 KB
testcase_06 AC 240 ms
101,164 KB
testcase_07 AC 212 ms
94,528 KB
testcase_08 AC 231 ms
101,140 KB
testcase_09 AC 221 ms
97,124 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N,D=map(int, input().split())
Square = []
P = []
M = []

for i in range(N+1):
    Square.append(i**2)
for i in range(1,N+1):
    for j in range(1,N+1):
        P.append(Square[i]+Square[j])
        M.append(Square[i]-Square[j]-D)
P=collections.Counter(P)
M=collections.Counter(M)
P = sorted( P.items() )
M = sorted( M.items() )

j = len(M)-1
ans = 0
mk,mv=M[j]
for pk, pv in P:
    while  mk+pk > 0 and j>=0:
        j-=1
        mk,mv=M[j]
    if mk+pk==0:
        ans += mv*pv
        j-=1
        mk,mv=M[j]

print(ans)    
0