結果

問題 No.800 四平方定理
ユーザー hogeandfugahogeandfuga
提出日時 2019-03-17 22:04:34
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 415 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 269,164 KB
最終ジャッジ日時 2023-09-22 06:26:17
合計ジャッジ時間 29,818 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
79,420 KB
testcase_01 AC 117 ms
82,592 KB
testcase_02 AC 120 ms
81,048 KB
testcase_03 AC 116 ms
81,824 KB
testcase_04 AC 114 ms
80,240 KB
testcase_05 AC 114 ms
81,020 KB
testcase_06 AC 123 ms
84,456 KB
testcase_07 AC 117 ms
82,508 KB
testcase_08 AC 121 ms
84,304 KB
testcase_09 AC 122 ms
83,464 KB
testcase_10 AC 868 ms
230,100 KB
testcase_11 AC 946 ms
230,600 KB
testcase_12 AC 897 ms
230,800 KB
testcase_13 AC 930 ms
230,188 KB
testcase_14 AC 1,025 ms
230,792 KB
testcase_15 AC 975 ms
230,748 KB
testcase_16 AC 1,017 ms
230,824 KB
testcase_17 AC 1,009 ms
230,892 KB
testcase_18 AC 987 ms
231,060 KB
testcase_19 AC 1,001 ms
231,072 KB
testcase_20 AC 92 ms
71,736 KB
testcase_21 AC 92 ms
71,464 KB
testcase_22 AC 1,082 ms
230,820 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 93 ms
71,628 KB
testcase_27 AC 95 ms
71,428 KB
testcase_28 AC 1,930 ms
269,164 KB
testcase_29 TLE -
testcase_30 AC 1,980 ms
269,116 KB
testcase_31 AC 1,639 ms
268,428 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