結果

問題 No.800 四平方定理
コンテスト
ユーザー ktgw0316
提出日時 2019-04-08 13:51:14
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 449 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 685 ms
コンパイル使用メモリ 20,576 KB
実行使用メモリ 31,388 KB
最終ジャッジ日時 2026-03-23 02:08:53
合計ジャッジ時間 85,954 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2 TLE * 1
other AC * 2 WA * 2 TLE * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import itertools

n, d = map(int, input().split())
count = 0
for x in range(1, n + 1):
    yMax = min(max(1, x*x + 1 + 1 - d), n)
    for y in range(1, yMax + 1):
        zMax = min(max(1, x*x + y*y + 1 - d), n)
        for z in range(1, zMax + 1):
            s = x*x + y*y + z*z - d
            if (s <= 0 or n*n < s):
                continue
            w = int(s ** 0.5 + 0.5)
            if (w*w == s):
                count += 1
print(count)
0