結果

問題 No.1593 Perfect Distance
コンテスト
ユーザー HAPPA
提出日時 2021-07-09 21:28:26
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 365 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 575 ms
コンパイル使用メモリ 20,732 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2026-03-22 17:39:45
合計ジャッジ時間 3,138 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
import math

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
MOD = 10 ** 9 + 7


def solve():
    n = int(input())
    nn = n * n

    res = 0
    for x in range(1, n):
        xx = x * x
        y = math.sqrt(nn - xx)
        if y.is_integer():
            res += 1
    print(res)


if __name__ == '__main__':
    solve()
0