結果

問題 No.1700 floor X
ユーザー Theta
提出日時 2022-12-20 11:50:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-18 01:45:37
合計ジャッジ時間 6,465 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt, floor


def is_sqrt_floor(n: int, x: int) -> bool:
    if x < 0:
        return False
    return (x+1) ** 2 > n >= x**2


def main():
    T = int(input())
    for _ in range(T):
        N = int(input())
        floor_candidate = floor(sqrt(N))
        for diff in range(-1, 3):
            if is_sqrt_floor(N, floor_candidate+diff):
                print(floor_candidate+diff)
                break
        else:
            raise ValueError


if __name__ == "__main__":
    main()
0