結果

問題 No.1980 [Cherry 4th Tune D] 停止距離
ユーザー 👑 KazunKazun
提出日時 2022-03-13 19:07:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 449 ms / 3,000 ms
コード長 1,510 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 96,128 KB
最終ジャッジ日時 2024-04-17 12:22:03
合計ジャッジ時間 14,849 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,968 KB
testcase_01 AC 180 ms
80,000 KB
testcase_02 AC 349 ms
90,480 KB
testcase_03 AC 278 ms
86,016 KB
testcase_04 AC 155 ms
78,976 KB
testcase_05 AC 313 ms
88,576 KB
testcase_06 AC 446 ms
95,744 KB
testcase_07 AC 449 ms
95,668 KB
testcase_08 AC 433 ms
96,012 KB
testcase_09 AC 444 ms
95,744 KB
testcase_10 AC 422 ms
96,096 KB
testcase_11 AC 438 ms
95,980 KB
testcase_12 AC 431 ms
95,796 KB
testcase_13 AC 426 ms
95,872 KB
testcase_14 AC 427 ms
95,744 KB
testcase_15 AC 446 ms
95,784 KB
testcase_16 AC 437 ms
95,652 KB
testcase_17 AC 434 ms
95,872 KB
testcase_18 AC 437 ms
95,872 KB
testcase_19 AC 436 ms
95,616 KB
testcase_20 AC 435 ms
95,488 KB
testcase_21 AC 435 ms
95,872 KB
testcase_22 AC 436 ms
95,596 KB
testcase_23 AC 440 ms
95,616 KB
testcase_24 AC 442 ms
96,128 KB
testcase_25 AC 442 ms
95,744 KB
testcase_26 AC 42 ms
52,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def General_Binary_Decrease_Search_Integer(L,R,cond,default=None):
    """条件式が単調減少であるとき, 整数上で二部探索を行う.
    L:解の下限
    R:解の上限
    cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす)
    default: Rで条件を満たさないときの返り値
    """

    if not(cond(L)): return default

    if cond(R): return R

    L-=1
    while R-L>1:
        C=L+(R-L)//2
        if cond(C): L=C
        else: R=C
    return L

#小数点以下第 k 位まで与えられる小数を 10^k 倍する.
def Decimal_to_Int(s: str, k: int, base=10):
    """ s*10^k を整数で出力する.

    s: 小数点を含むかもしれない数
    k: 小数点以下高々何位までか?
    base: 基数
    """

    if "." not in s:
        return int(s,base)*pow(base,k)

    m=s.index(".")
    return int(s.replace(".",""))*pow(base,k-(len(s)-m-1))

#==================================================
def answer(X):
    a,b=divmod(X,100)
    return str(a)+"."+str(b).zfill(2)

#==================================================
N=int(input())

Ans=[None]*N

for n in range(N):
    T,mu,L=input().split()

    T_100=Decimal_to_Int(T,2)
    mu_100=Decimal_to_Int(mu,2)
    L_100=Decimal_to_Int(L,2)

    check=lambda w:w*(25*w+18*T_100*mu_100)<=6480*mu_100*L_100
    V_100=General_Binary_Decrease_Search_Integer(0,5100*100,check,-1)
    Ans[n]=answer(V_100)

print(*Ans,sep="\n")
0