結果

問題 No.800 四平方定理
ユーザー hogeandfugahogeandfuga
提出日時 2019-03-17 22:04:34
言語 PyPy3
(7.3.8)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 415 bytes
コンパイル時間 248 ms
使用メモリ 272,016 KB
最終ジャッジ日時 2023-02-11 07:14:04
合計ジャッジ時間 29,943 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 112 ms
83,720 KB
testcase_01 AC 118 ms
86,992 KB
testcase_02 AC 117 ms
85,400 KB
testcase_03 AC 118 ms
86,016 KB
testcase_04 AC 116 ms
84,964 KB
testcase_05 AC 117 ms
85,512 KB
testcase_06 AC 124 ms
88,772 KB
testcase_07 AC 117 ms
86,720 KB
testcase_08 AC 121 ms
88,652 KB
testcase_09 AC 123 ms
87,620 KB
testcase_10 AC 848 ms
219,312 KB
testcase_11 AC 922 ms
233,936 KB
testcase_12 AC 914 ms
233,872 KB
testcase_13 AC 921 ms
219,576 KB
testcase_14 AC 958 ms
233,988 KB
testcase_15 AC 944 ms
233,956 KB
testcase_16 AC 950 ms
234,164 KB
testcase_17 AC 1,016 ms
233,876 KB
testcase_18 AC 1,009 ms
234,164 KB
testcase_19 AC 968 ms
234,168 KB
testcase_20 AC 94 ms
76,236 KB
testcase_21 AC 93 ms
76,160 KB
testcase_22 AC 1,018 ms
234,096 KB
testcase_23 AC 1,989 ms
271,616 KB
testcase_24 AC 1,950 ms
271,636 KB
testcase_25 TLE -
testcase_26 AC 92 ms
76,144 KB
testcase_27 AC 91 ms
76,116 KB
testcase_28 AC 1,828 ms
271,648 KB
testcase_29 AC 1,888 ms
271,676 KB
testcase_30 AC 1,985 ms
271,632 KB
testcase_31 AC 1,682 ms
270,852 KB
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n, d = map(int, input().split())

cnt = defaultdict(int)
check = set()
for x in range(1, n+1):
    for y in range(1, n+1):
        tmp = x**2 + y**2
        cnt[tmp] += 1
        if cnt[tmp] == 1:
            check.add(tmp)

ans = 0
for z in range(1, n+1):
    for w in range(1, n+1):
        tmp = w**2 + d - z**2
        if tmp in check:
            ans += cnt[tmp]
print(ans)
0