結果

問題 No.800 四平方定理
ユーザー ktgw0316
提出日時 2019-04-08 13:51:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 449 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 24,640 KB
最終ジャッジ日時 2024-07-01 22:51:50
合計ジャッジ時間 6,588 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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