結果

問題 No.800 四平方定理
ユーザー FromBooskaFromBooska
提出日時 2023-03-03 04:57:24
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 595 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 416,460 KB
最終ジャッジ日時 2023-10-17 23:30:05
合計ジャッジ時間 22,091 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
73,256 KB
testcase_01 AC 75 ms
78,244 KB
testcase_02 AC 70 ms
74,812 KB
testcase_03 AC 72 ms
75,868 KB
testcase_04 AC 72 ms
75,620 KB
testcase_05 AC 73 ms
76,520 KB
testcase_06 AC 81 ms
82,120 KB
testcase_07 AC 84 ms
83,080 KB
testcase_08 AC 92 ms
89,008 KB
testcase_09 AC 78 ms
79,916 KB
testcase_10 AC 1,196 ms
247,948 KB
testcase_11 AC 1,261 ms
253,508 KB
testcase_12 AC 1,368 ms
266,492 KB
testcase_13 AC 999 ms
241,456 KB
testcase_14 AC 1,124 ms
238,796 KB
testcase_15 AC 1,450 ms
267,040 KB
testcase_16 AC 1,118 ms
241,424 KB
testcase_17 AC 1,158 ms
241,380 KB
testcase_18 AC 1,586 ms
281,292 KB
testcase_19 AC 1,579 ms
283,876 KB
testcase_20 AC 39 ms
53,504 KB
testcase_21 AC 40 ms
55,552 KB
testcase_22 AC 1,556 ms
278,960 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 40 ms
53,592 KB
testcase_27 AC 39 ms
53,592 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

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
        if calc > 0:
            wDz[calc] += 1
        
ans = 0
for num in wDz:
    ans += xy[num]*wDz[num]
print(ans)
0