結果

問題 No.800 四平方定理
ユーザー rlangevinrlangevin
提出日時 2022-08-20 11:40:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,444 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 82,484 KB
実行使用メモリ 253,852 KB
最終ジャッジ日時 2024-04-17 11:02:07
合計ジャッジ時間 17,325 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
66,176 KB
testcase_01 AC 60 ms
70,272 KB
testcase_02 AC 57 ms
68,096 KB
testcase_03 AC 59 ms
69,632 KB
testcase_04 AC 59 ms
67,968 KB
testcase_05 AC 58 ms
69,632 KB
testcase_06 AC 63 ms
71,552 KB
testcase_07 AC 70 ms
74,240 KB
testcase_08 AC 73 ms
77,696 KB
testcase_09 AC 60 ms
69,632 KB
testcase_10 AC 580 ms
202,596 KB
testcase_11 AC 590 ms
202,156 KB
testcase_12 AC 670 ms
221,604 KB
testcase_13 AC 440 ms
164,592 KB
testcase_14 AC 482 ms
179,628 KB
testcase_15 AC 657 ms
221,404 KB
testcase_16 AC 490 ms
179,584 KB
testcase_17 AC 470 ms
185,492 KB
testcase_18 AC 857 ms
246,852 KB
testcase_19 AC 834 ms
247,000 KB
testcase_20 AC 40 ms
53,888 KB
testcase_21 AC 39 ms
53,760 KB
testcase_22 AC 775 ms
237,428 KB
testcase_23 AC 1,444 ms
250,676 KB
testcase_24 AC 945 ms
248,472 KB
testcase_25 AC 1,379 ms
250,916 KB
testcase_26 AC 39 ms
53,492 KB
testcase_27 AC 39 ms
53,760 KB
testcase_28 AC 807 ms
253,424 KB
testcase_29 AC 1,146 ms
244,300 KB
testcase_30 AC 955 ms
253,852 KB
testcase_31 AC 887 ms
247,072 KB
testcase_32 AC 995 ms
239,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


N, D = map(int, input().split())
maxv = N * N + D + 5
S = defaultdict(int)
for i in range(1, N + 1):
    for j in range(1, N + 1):
        v = D + i * i - j * j
        if v < 0:
            break
        S[v] += 1
        
ans = 0
for i in range(1, N + 1):
    for j in range(1, N + 1):
        v = i * i + j * j
        if v >= maxv - 1:
            break
        ans += S[v]
print(ans)
0