結果

問題 No.800 四平方定理
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-03-18 09:41:42
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 140,304 KB
最終ジャッジ日時 2023-09-24 23:18:36
合計ジャッジ時間 7,808 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
139,452 KB
testcase_01 AC 119 ms
139,876 KB
testcase_02 AC 120 ms
140,092 KB
testcase_03 AC 122 ms
140,112 KB
testcase_04 AC 120 ms
139,872 KB
testcase_05 AC 119 ms
139,956 KB
testcase_06 AC 118 ms
139,748 KB
testcase_07 AC 118 ms
139,752 KB
testcase_08 AC 117 ms
139,732 KB
testcase_09 AC 118 ms
139,872 KB
testcase_10 AC 188 ms
140,108 KB
testcase_11 AC 196 ms
140,008 KB
testcase_12 AC 193 ms
139,884 KB
testcase_13 AC 191 ms
140,080 KB
testcase_14 AC 197 ms
140,288 KB
testcase_15 AC 199 ms
140,232 KB
testcase_16 AC 193 ms
140,176 KB
testcase_17 AC 194 ms
140,204 KB
testcase_18 AC 204 ms
140,208 KB
testcase_19 AC 202 ms
140,244 KB
testcase_20 AC 104 ms
134,176 KB
testcase_21 AC 106 ms
133,884 KB
testcase_22 AC 201 ms
140,232 KB
testcase_23 AC 269 ms
140,040 KB
testcase_24 AC 260 ms
140,304 KB
testcase_25 AC 265 ms
140,256 KB
testcase_26 AC 104 ms
134,156 KB
testcase_27 AC 106 ms
134,044 KB
testcase_28 AC 264 ms
140,120 KB
testcase_29 AC 272 ms
140,168 KB
testcase_30 AC 262 ms
140,108 KB
testcase_31 AC 253 ms
139,888 KB
testcase_32 AC 265 ms
140,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

from collections import defaultdict 
# cnt = defaultdict(int)
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):
        cnt[ lst[i] + lst[j] ] += 1


ans = 0

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

print(ans)
0