結果

問題 No.800 四平方定理
ユーザー kohei2019kohei2019
提出日時 2022-04-12 22:28:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,182 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 854 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 217,740 KB
最終ジャッジ日時 2023-08-23 07:46:06
合計ジャッジ時間 17,054 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
77,960 KB
testcase_01 AC 114 ms
79,920 KB
testcase_02 AC 116 ms
78,980 KB
testcase_03 AC 115 ms
79,276 KB
testcase_04 AC 115 ms
79,408 KB
testcase_05 AC 115 ms
79,512 KB
testcase_06 AC 115 ms
79,988 KB
testcase_07 AC 119 ms
82,112 KB
testcase_08 AC 118 ms
84,696 KB
testcase_09 AC 113 ms
79,628 KB
testcase_10 AC 514 ms
166,784 KB
testcase_11 AC 503 ms
176,376 KB
testcase_12 AC 696 ms
166,984 KB
testcase_13 AC 396 ms
167,164 KB
testcase_14 AC 409 ms
176,632 KB
testcase_15 AC 536 ms
166,976 KB
testcase_16 AC 414 ms
177,008 KB
testcase_17 AC 463 ms
176,688 KB
testcase_18 AC 631 ms
176,672 KB
testcase_19 AC 604 ms
176,468 KB
testcase_20 AC 91 ms
71,540 KB
testcase_21 AC 91 ms
71,432 KB
testcase_22 AC 646 ms
176,604 KB
testcase_23 AC 1,182 ms
210,256 KB
testcase_24 AC 835 ms
178,392 KB
testcase_25 AC 1,125 ms
210,496 KB
testcase_26 AC 90 ms
71,536 KB
testcase_27 AC 92 ms
71,408 KB
testcase_28 AC 718 ms
178,220 KB
testcase_29 AC 952 ms
217,740 KB
testcase_30 AC 694 ms
178,352 KB
testcase_31 AC 596 ms
176,556 KB
testcase_32 AC 785 ms
178,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N,D = map(int, input().split())
lszwD = collections.Counter()
for i in range(1,N+1):
    for j in range(1,N+1):
        a = i**2-j**2+D
        if a >= 2:
            lszwD[a] += 1
ans = 0
for i in range(1,N+1):
    for j in range(i,N+1):
        if i == j:
            ans += lszwD[i**2+j**2]
        else:
            ans += lszwD[i**2+j**2]*2
print(ans)
0