結果

問題 No.800 四平方定理
ユーザー rlangevinrlangevin
提出日時 2022-08-20 11:39:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 100,736 KB
最終ジャッジ日時 2024-04-17 11:00:57
合計ジャッジ時間 3,844 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
59,392 KB
testcase_01 AC 48 ms
60,672 KB
testcase_02 AC 43 ms
60,588 KB
testcase_03 AC 43 ms
60,544 KB
testcase_04 AC 42 ms
59,776 KB
testcase_05 AC 43 ms
60,928 KB
testcase_06 AC 44 ms
61,184 KB
testcase_07 AC 46 ms
61,824 KB
testcase_08 AC 48 ms
62,720 KB
testcase_09 AC 48 ms
60,544 KB
testcase_10 AC 88 ms
80,256 KB
testcase_11 AC 87 ms
80,512 KB
testcase_12 AC 98 ms
82,688 KB
testcase_13 AC 82 ms
76,416 KB
testcase_14 AC 79 ms
78,208 KB
testcase_15 AC 96 ms
82,048 KB
testcase_16 AC 85 ms
78,080 KB
testcase_17 AC 80 ms
77,696 KB
testcase_18 AC 104 ms
86,912 KB
testcase_19 AC 105 ms
86,784 KB
testcase_20 AC 38 ms
51,840 KB
testcase_21 AC 35 ms
51,968 KB
testcase_22 AC 108 ms
87,040 KB
testcase_23 AC 154 ms
100,736 KB
testcase_24 AC 119 ms
91,392 KB
testcase_25 AC 152 ms
100,352 KB
testcase_26 AC 34 ms
51,584 KB
testcase_27 AC 38 ms
59,648 KB
testcase_28 AC 123 ms
91,776 KB
testcase_29 AC 142 ms
96,128 KB
testcase_30 AC 154 ms
92,416 KB
testcase_31 AC 116 ms
88,960 KB
testcase_32 AC 125 ms
92,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, D = map(int, input().split())
maxv = N * N + D + 5
S = [0] * maxv
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