結果

問題 No.800 四平方定理
ユーザー TakoKurageTakoKurage
提出日時 2019-03-17 23:00:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 987 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 91,672 KB
最終ジャッジ日時 2023-09-22 09:33:12
合計ジャッジ時間 6,970 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
76,960 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 294 ms
77,020 KB
testcase_07 WA -
testcase_08 AC 96 ms
76,556 KB
testcase_09 AC 255 ms
76,816 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, D = [int(i) for i in input().split()]

ma = N * N + D
count = 0
for x in range(1, N + 1):
    x2 = x * x
    if x2 > ma:
        break
    for y in range(x, N + 1):
        y2 = y * y
        if x2 + y2 > ma:
            break
        for z in range(y, N + 1):
            z2 = z * z
            w2 = x2 + y2 + z2 - D
            if w2 > ma:
                break
            if w2 < 0:
                continue
            w = int(w2 ** 0.5)
            if w2 == w * w:
                num = len(set([x, y, z])) - 1
                count += [1, 3, 6][num]
print(count)
0