結果

問題 No.800 四平方定理
ユーザー ntudantuda
提出日時 2024-01-03 15:34:24
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 932 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 82,964 KB
最終ジャッジ日時 2024-01-03 15:34:30
合計ジャッジ時間 5,432 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
82,588 KB
testcase_01 AC 103 ms
75,884 KB
testcase_02 AC 82 ms
75,776 KB
testcase_03 AC 84 ms
75,760 KB
testcase_04 AC 101 ms
76,100 KB
testcase_05 AC 92 ms
75,780 KB
testcase_06 AC 100 ms
75,756 KB
testcase_07 AC 112 ms
75,792 KB
testcase_08 AC 34 ms
53,588 KB
testcase_09 AC 108 ms
76,020 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 = map(int, input().split())
# x >= y >= z とする
cnt = 0
ans = 0
for w in range(1, N + 1):
    wd = w * w + D
    for x in range(max(1, int((wd / 3) ** 0.5)), N + 1):
        x2 = x * x
        if x2 > wd:
            break
        for y in range(max(1, int(((wd - x2) / 2) ** 0.5)), x + 1):
            y2 = y * y
            if x2 + y2 > wd:
                break
            wdxy = wd - x2 - y2
            tz = int(wdxy ** 0.5)
            for i in range(max(1, tz - 1), tz + 2):
                if i * i == wdxy:
                    if i > N or i > y:
                        continue
                    z = i
                    # print(x, y, z, w, x*x+y*y+z*z,w*w +D)
                    if x == y and y == z:
                        ans += 1
                    elif x == y or y == z:
                        ans += 3
                    else:
                        ans += 6
                    break

print(ans)
0