結果

問題 No.800 四平方定理
ユーザー ireenaireena
提出日時 2022-01-22 16:27:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 463 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 201,508 KB
最終ジャッジ日時 2023-08-18 10:08:46
合計ジャッジ時間 9,939 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
77,052 KB
testcase_01 AC 87 ms
78,380 KB
testcase_02 AC 86 ms
77,604 KB
testcase_03 AC 87 ms
77,872 KB
testcase_04 AC 86 ms
77,732 KB
testcase_05 AC 85 ms
78,020 KB
testcase_06 AC 88 ms
78,852 KB
testcase_07 AC 92 ms
78,108 KB
testcase_08 AC 87 ms
78,852 KB
testcase_09 AC 86 ms
78,472 KB
testcase_10 AC 249 ms
138,420 KB
testcase_11 AC 263 ms
146,104 KB
testcase_12 AC 296 ms
144,880 KB
testcase_13 AC 218 ms
141,344 KB
testcase_14 AC 225 ms
146,104 KB
testcase_15 AC 254 ms
145,632 KB
testcase_16 AC 229 ms
146,776 KB
testcase_17 AC 216 ms
146,912 KB
testcase_18 AC 266 ms
146,588 KB
testcase_19 AC 268 ms
146,812 KB
testcase_20 AC 72 ms
71,272 KB
testcase_21 AC 70 ms
71,296 KB
testcase_22 AC 275 ms
146,904 KB
testcase_23 AC 460 ms
200,956 KB
testcase_24 AC 443 ms
201,508 KB
testcase_25 AC 463 ms
201,020 KB
testcase_26 AC 73 ms
71,184 KB
testcase_27 AC 74 ms
71,200 KB
testcase_28 AC 397 ms
200,848 KB
testcase_29 AC 443 ms
201,304 KB
testcase_30 AC 391 ms
200,792 KB
testcase_31 AC 350 ms
192,176 KB
testcase_32 AC 399 ms
201,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, D = map(int, input().split())
mx = 2 * pow(N, 2)

def make_cnt(n, d=None):
    cnt = [0] * (mx + 1)
    for i in range(1, n+1):
        for j in range(1, n+1):
            if d is not None:
                tmp = pow(i, 2) - pow(j, 2) + d
            else:
                tmp = pow(i, 2) + pow(j, 2)
            if 0 < tmp < mx + 1:
                cnt[tmp] += 1
    return cnt

xy_cnt = make_cnt(N)
wz_cnt = make_cnt(N, D)

ans = 0
for i in range(1, mx+1):
    ans += xy_cnt[i] * wz_cnt[i]

print(ans)
0