結果

問題 No.800 四平方定理
ユーザー FromBooskaFromBooska
提出日時 2023-03-03 04:45:06
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 569 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 275,532 KB
最終ジャッジ日時 2023-10-17 23:19:55
合計ジャッジ時間 25,074 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,172 KB
testcase_01 AC 87 ms
81,888 KB
testcase_02 AC 79 ms
77,440 KB
testcase_03 AC 81 ms
80,496 KB
testcase_04 AC 78 ms
77,136 KB
testcase_05 AC 83 ms
79,268 KB
testcase_06 AC 94 ms
85,228 KB
testcase_07 AC 84 ms
80,880 KB
testcase_08 AC 93 ms
85,220 KB
testcase_09 AC 87 ms
82,328 KB
testcase_10 AC 1,613 ms
268,708 KB
testcase_11 AC 1,833 ms
273,264 KB
testcase_12 AC 1,795 ms
272,768 KB
testcase_13 AC 1,711 ms
270,520 KB
testcase_14 AC 1,847 ms
273,276 KB
testcase_15 AC 1,809 ms
272,756 KB
testcase_16 AC 1,821 ms
275,532 KB
testcase_17 AC 1,859 ms
275,532 KB
testcase_18 AC 1,770 ms
273,264 KB
testcase_19 AC 1,770 ms
275,532 KB
testcase_20 AC 42 ms
53,432 KB
testcase_21 AC 42 ms
53,432 KB
testcase_22 AC 1,840 ms
275,524 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 公式解説より
# 2重ループは可能、を押し進めるべきだった
# x, yで作れる数を全探索
# w, D, zで作れる数を全探索
# その組合せ数が答え

N, D = map(int, input().split())
from collections import defaultdict
xy = defaultdict(int)
for x in range(1, N+1):
    for y in range(1, N+1):
        calc = x**2+y**2
        xy[calc] += 1
wDz = defaultdict(int)
for w in range(1, N+1):
    for z in range(1, N+1):
        calc = w**2+D-z**2
        wDz[calc] += 1
        
ans = 0
for num in xy:
    ans += xy[num]*wDz[num]
print(ans)
0