結果

問題 No.800 四平方定理
ユーザー hogeandfugahogeandfuga
提出日時 2019-03-17 22:40:40
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,163 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 260,568 KB
最終ジャッジ日時 2023-09-22 08:39:41
合計ジャッジ時間 18,123 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
79,664 KB
testcase_01 AC 116 ms
83,000 KB
testcase_02 AC 111 ms
80,688 KB
testcase_03 AC 113 ms
81,660 KB
testcase_04 AC 111 ms
81,096 KB
testcase_05 AC 112 ms
81,840 KB
testcase_06 AC 118 ms
84,960 KB
testcase_07 AC 118 ms
85,748 KB
testcase_08 AC 126 ms
89,152 KB
testcase_09 AC 115 ms
82,972 KB
testcase_10 AC 544 ms
198,596 KB
testcase_11 AC 536 ms
198,508 KB
testcase_12 AC 601 ms
220,156 KB
testcase_13 AC 486 ms
188,540 KB
testcase_14 AC 550 ms
198,468 KB
testcase_15 AC 575 ms
220,032 KB
testcase_16 AC 516 ms
198,324 KB
testcase_17 AC 526 ms
198,316 KB
testcase_18 AC 674 ms
260,568 KB
testcase_19 AC 875 ms
260,544 KB
testcase_20 AC 116 ms
71,540 KB
testcase_21 AC 91 ms
71,668 KB
testcase_22 AC 717 ms
219,940 KB
testcase_23 AC 1,132 ms
257,756 KB
testcase_24 AC 1,102 ms
258,320 KB
testcase_25 AC 1,163 ms
258,108 KB
testcase_26 AC 92 ms
71,716 KB
testcase_27 AC 92 ms
71,756 KB
testcase_28 AC 936 ms
258,060 KB
testcase_29 AC 1,044 ms
258,384 KB
testcase_30 AC 966 ms
251,816 KB
testcase_31 AC 897 ms
259,644 KB
testcase_32 AC 993 ms
251,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n, d = map(int, input().split())

cnt = defaultdict(int)
for x in range(1, n+1):
    for y in range(x, n+1):
        if y == x:
            cnt[x**2+y**2] += 1
        else:
            cnt[x**2+y**2] += 2

ans = 0
for w in range(1, n+1):
    tmp = w**2+d
    for z in range(1, n+1):
        if tmp <= z**2:
            break
        ans += cnt[tmp - z**2]
print(ans)
0