結果

問題 No.800 四平方定理
ユーザー 💕💖💞💕💖💞
提出日時 2019-05-11 19:08:50
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 483 bytes
コンパイル時間 1,606 ms
コンパイル使用メモリ 86,544 KB
実行使用メモリ 522,648 KB
最終ジャッジ日時 2023-09-14 18:15:19
合計ジャッジ時間 26,998 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
83,276 KB
testcase_01 AC 114 ms
92,532 KB
testcase_02 AC 106 ms
87,036 KB
testcase_03 AC 111 ms
88,956 KB
testcase_04 AC 105 ms
85,336 KB
testcase_05 AC 110 ms
88,208 KB
testcase_06 AC 126 ms
97,872 KB
testcase_07 AC 113 ms
91,188 KB
testcase_08 AC 121 ms
98,076 KB
testcase_09 AC 123 ms
93,364 KB
testcase_10 AC 1,542 ms
312,648 KB
testcase_11 AC 1,679 ms
330,728 KB
testcase_12 AC 1,656 ms
331,404 KB
testcase_13 AC 1,591 ms
308,812 KB
testcase_14 AC 1,703 ms
330,404 KB
testcase_15 AC 1,692 ms
328,772 KB
testcase_16 AC 1,690 ms
331,652 KB
testcase_17 AC 1,672 ms
331,792 KB
testcase_18 AC 1,720 ms
331,020 KB
testcase_19 AC 1,645 ms
331,284 KB
testcase_20 AC 73 ms
71,640 KB
testcase_21 AC 71 ms
71,260 KB
testcase_22 AC 1,754 ms
331,432 KB
testcase_23 MLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N, D = map(int, input().split())


cnt1 = {}
for n1 in range(1, N+1):
    for n2 in range(1, N+1):
        v = n1**2 + n2**2
        if cnt1.get(v) is None:
            cnt1[v] = 0
        cnt1[v] += 1

cnt2 = {}
for n1 in range(1, N+1):
    for n2 in range(1, N+1):
        v = n1**2 - n2**2 + D
        if cnt2.get(v) is None:
            cnt2[v] = 0
        cnt2[v] += 1

same_keys = set(cnt1) & set(cnt2)
r = 0
for k in same_keys:
    r += cnt1[k] * cnt2[k]

print(r)
0