結果

問題 No.800 四平方定理
ユーザー ronpooronpoo
提出日時 2023-08-25 14:37:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 201,444 KB
最終ジャッジ日時 2023-08-25 14:38:00
合計ジャッジ時間 6,989 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
77,408 KB
testcase_01 AC 87 ms
78,496 KB
testcase_02 AC 75 ms
77,952 KB
testcase_03 AC 77 ms
77,984 KB
testcase_04 AC 74 ms
77,760 KB
testcase_05 AC 73 ms
78,048 KB
testcase_06 AC 73 ms
79,084 KB
testcase_07 AC 78 ms
78,356 KB
testcase_08 AC 76 ms
79,032 KB
testcase_09 AC 74 ms
78,736 KB
testcase_10 AC 176 ms
138,340 KB
testcase_11 AC 167 ms
146,012 KB
testcase_12 AC 162 ms
144,644 KB
testcase_13 AC 153 ms
141,244 KB
testcase_14 AC 162 ms
145,868 KB
testcase_15 AC 159 ms
145,436 KB
testcase_16 AC 162 ms
146,536 KB
testcase_17 AC 170 ms
146,448 KB
testcase_18 AC 169 ms
146,200 KB
testcase_19 AC 186 ms
146,436 KB
testcase_20 AC 62 ms
71,344 KB
testcase_21 AC 60 ms
71,096 KB
testcase_22 AC 160 ms
146,600 KB
testcase_23 AC 241 ms
201,436 KB
testcase_24 AC 232 ms
201,412 KB
testcase_25 AC 243 ms
200,860 KB
testcase_26 AC 60 ms
70,900 KB
testcase_27 AC 57 ms
71,388 KB
testcase_28 AC 242 ms
200,708 KB
testcase_29 AC 240 ms
200,780 KB
testcase_30 AC 273 ms
200,656 KB
testcase_31 AC 231 ms
192,156 KB
testcase_32 AC 236 ms
201,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ans = 0
cnt1 = [0] * (2*N**2 + 10)
cnt2 = [0] * (2*N**2 + 10)
L = len(cnt1)
for x in range(1, N+1):
    for y in range(1, N+1):
        v = x**2+y**2
        if 0 <= v < L:
            cnt1[v] += 1
        
for z in range(1, N+1):
    for w in range(1, N+1):        
        v = D + w**2 - z**2
        if 0 <= v < L:
            cnt2[v] += 1
ans = 0        
for i in range(L):
    ans += cnt1[i] * cnt2[i]
print(ans)
0