結果

問題 No.800 四平方定理
ユーザー tobusakanatobusakana
提出日時 2022-10-02 17:19:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,779 ms / 2,000 ms
コード長 514 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 316,360 KB
最終ジャッジ日時 2023-08-26 15:19:19
合計ジャッジ時間 24,861 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
79,356 KB
testcase_01 AC 119 ms
82,792 KB
testcase_02 AC 111 ms
81,136 KB
testcase_03 AC 111 ms
81,488 KB
testcase_04 AC 109 ms
80,828 KB
testcase_05 AC 110 ms
81,636 KB
testcase_06 AC 116 ms
83,780 KB
testcase_07 AC 117 ms
85,080 KB
testcase_08 AC 123 ms
88,440 KB
testcase_09 AC 118 ms
82,900 KB
testcase_10 AC 768 ms
206,848 KB
testcase_11 AC 798 ms
216,872 KB
testcase_12 AC 877 ms
240,704 KB
testcase_13 AC 692 ms
184,296 KB
testcase_14 AC 765 ms
205,368 KB
testcase_15 AC 879 ms
240,664 KB
testcase_16 AC 743 ms
206,468 KB
testcase_17 AC 779 ms
208,580 KB
testcase_18 AC 925 ms
240,436 KB
testcase_19 AC 988 ms
240,540 KB
testcase_20 AC 85 ms
71,704 KB
testcase_21 AC 85 ms
71,812 KB
testcase_22 AC 946 ms
240,536 KB
testcase_23 AC 1,723 ms
316,024 KB
testcase_24 AC 1,541 ms
275,804 KB
testcase_25 AC 1,779 ms
316,360 KB
testcase_26 AC 92 ms
71,972 KB
testcase_27 AC 85 ms
71,964 KB
testcase_28 AC 1,399 ms
276,108 KB
testcase_29 AC 1,593 ms
294,528 KB
testcase_30 AC 1,464 ms
276,184 KB
testcase_31 AC 1,270 ms
263,560 KB
testcase_32 AC 1,485 ms
275,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

from collections import defaultdict
left = defaultdict(int)
for x in range(1, N + 1):
    for y in range(1, N + 1):
        left[x**2 + y**2] += 1
        
right = defaultdict(int)
for w in range(1, N + 1):
    for z in range(1, N + 1):
        val = w**2 - z**2 + D
        if val < 0:
            break
        right[w**2 - z**2 + D] += 1
        
ans = 0
for key, value in left.items():
    if key in right:
        ans += right[key] * value
        
print(ans)
        
        
0