結果

問題 No.1593 Perfect Distance
ユーザー HAPPA
提出日時 2021-07-09 22:29:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-01 17:08:15
合計ジャッジ時間 2,135 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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
        l = int(math.sqrt(nn - xx))
        for y in range(l - 1, l + 1):
            if x * x + y * y == nn:
                res += 1
                break
    print(res)


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