結果

問題 No.800 四平方定理
ユーザー tpynerivertpyneriver
提出日時 2019-03-18 02:14:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 305 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 140,328 KB
最終ジャッジ日時 2023-09-22 16:29:43
合計ジャッジ時間 7,710 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
139,396 KB
testcase_01 AC 125 ms
139,964 KB
testcase_02 AC 125 ms
139,700 KB
testcase_03 AC 125 ms
139,664 KB
testcase_04 AC 128 ms
139,996 KB
testcase_05 AC 125 ms
139,904 KB
testcase_06 AC 126 ms
140,092 KB
testcase_07 AC 123 ms
139,680 KB
testcase_08 AC 125 ms
139,860 KB
testcase_09 AC 125 ms
139,904 KB
testcase_10 AC 183 ms
140,164 KB
testcase_11 AC 200 ms
140,060 KB
testcase_12 AC 201 ms
140,096 KB
testcase_13 AC 194 ms
140,056 KB
testcase_14 AC 198 ms
140,196 KB
testcase_15 AC 198 ms
140,016 KB
testcase_16 AC 202 ms
140,136 KB
testcase_17 AC 197 ms
140,256 KB
testcase_18 AC 192 ms
139,992 KB
testcase_19 AC 204 ms
140,052 KB
testcase_20 AC 112 ms
133,892 KB
testcase_21 AC 111 ms
134,228 KB
testcase_22 AC 199 ms
140,000 KB
testcase_23 AC 305 ms
140,152 KB
testcase_24 AC 268 ms
140,292 KB
testcase_25 AC 293 ms
140,148 KB
testcase_26 AC 113 ms
134,172 KB
testcase_27 AC 113 ms
134,068 KB
testcase_28 AC 275 ms
140,164 KB
testcase_29 AC 286 ms
140,328 KB
testcase_30 AC 272 ms
139,888 KB
testcase_31 AC 274 ms
140,056 KB
testcase_32 AC 282 ms
140,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

from collections import defaultdict 
cnt = [0] * (8*10**6 + 2)


lst = [ i**2 for i in range(1, N+1)]

for i in range(N):
    for j in range(N):
        # if i == j:
        cnt[ lst[i] + lst[j] ] += 1
        # else:
        #     cnt[ lst[i] + lst[j] ] += 2

ans = 0

for i in range(N):
    for j in range(N):
        x,y = lst[i], lst[j]
        # if i == j : 
        ans += cnt[ max(0, y+D - x)]

print(ans)
            
0