結果

問題 No.1700 floor X
ユーザー kept1994kept1994
提出日時 2021-11-21 23:33:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 1,253 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 78,500 KB
最終ジャッジ日時 2023-09-16 09:38:14
合計ジャッジ時間 8,396 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,040 KB
testcase_01 AC 132 ms
78,020 KB
testcase_02 AC 132 ms
78,424 KB
testcase_03 AC 131 ms
78,372 KB
testcase_04 AC 135 ms
77,960 KB
testcase_05 AC 134 ms
78,252 KB
testcase_06 AC 132 ms
78,132 KB
testcase_07 AC 133 ms
78,128 KB
testcase_08 AC 131 ms
78,252 KB
testcase_09 AC 133 ms
78,380 KB
testcase_10 AC 130 ms
78,148 KB
testcase_11 AC 131 ms
78,348 KB
testcase_12 AC 134 ms
78,292 KB
testcase_13 AC 133 ms
78,252 KB
testcase_14 AC 135 ms
78,220 KB
testcase_15 AC 132 ms
78,288 KB
testcase_16 AC 131 ms
77,948 KB
testcase_17 AC 130 ms
78,348 KB
testcase_18 AC 132 ms
78,380 KB
testcase_19 AC 131 ms
78,288 KB
testcase_20 AC 133 ms
78,212 KB
testcase_21 AC 143 ms
78,172 KB
testcase_22 AC 140 ms
78,216 KB
testcase_23 AC 140 ms
78,376 KB
testcase_24 AC 142 ms
78,232 KB
testcase_25 AC 140 ms
78,144 KB
testcase_26 AC 142 ms
78,344 KB
testcase_27 AC 141 ms
77,984 KB
testcase_28 AC 143 ms
78,268 KB
testcase_29 AC 141 ms
78,312 KB
testcase_30 AC 139 ms
78,040 KB
testcase_31 AC 142 ms
78,144 KB
testcase_32 AC 142 ms
78,248 KB
testcase_33 AC 146 ms
78,372 KB
testcase_34 AC 146 ms
78,364 KB
testcase_35 AC 144 ms
78,500 KB
testcase_36 AC 144 ms
78,408 KB
testcase_37 AC 140 ms
78,340 KB
testcase_38 AC 141 ms
78,348 KB
testcase_39 AC 140 ms
78,164 KB
testcase_40 AC 142 ms
78,372 KB
testcase_41 AC 131 ms
78,428 KB
testcase_42 AC 72 ms
71,168 KB
testcase_43 AC 137 ms
78,260 KB
testcase_44 AC 135 ms
78,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
from sys import stdin

def main():
    T = int(input())
    # True ------ ok | ng ---- False
    def is_ok(k: int, nn):
        return k ** 2 <= nn

    def binSearch(ok: int, ng: int, nn):
        # print(ok, ng)              # はじめの2値の状態
        while abs(ok - ng) > 1:     # 終了条件(差が1となり境界を見つけた時)
            mid = (ok + ng) // 2
            # print("target > ", mid)
            result = is_ok(mid, nn)
            # print(result)
            if result:
                ok = mid            # midが条件を満たすならmidまではokなのでokの方を真ん中まで持っていく
            else:
                ng = mid            # midが条件を満たさないならmidまではngなのでngの方を真ん中まで持っていく
            # print(ok, ng)          # 半分に切り分ける毎の2値の状態
        return ok    # 関数呼び出し時の引数のngは絶対評価されないのでngに書く値が答えになりうるならその数マイナス1を指定する。

    for _ in range(T):
        N = int(input())
        ans = binSearch(1, 10 ** 9 + 1, N)
        print(ans)
    return
            

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