結果

問題 No.1700 floor X
ユーザー norioc
提出日時 2025-06-10 10:34:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 82,848 KB
実行使用メモリ 77,572 KB
最終ジャッジ日時 2025-06-10 10:34:47
合計ジャッジ時間 8,756 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

def bsearch(low: int, high: int, fun, is_complement=False) -> int:
    def pred(x: int) -> bool:
        return not fun(x) if is_complement else fun(x)

    lo = low
    hi = high
    res = low
    while lo <= hi:
        m = (lo + hi) // 2
        if pred(m):
            res = max(res, m)
            lo = m + 1
        else:
            hi = m - 1

    return res + 1 if is_complement else res


def solve():
    def f(x):
        return x*x <= N

    N = int(input())
    return bsearch(0, N, f)


T = int(input())
for _ in range(T):
    ans = solve()
    print(ans)
0