結果

問題 No.456 Millions of Submits!
ユーザー lam6er
提出日時 2025-04-16 00:59:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,434 ms / 4,500 ms
コード長 1,267 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 285,956 KB
最終ジャッジ日時 2025-04-16 01:00:36
合計ジャッジ時間 7,114 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys

def main():
    input = sys.stdin.read().split()
    m = int(input[0])
    idx = 1
    for _ in range(m):
        a = int(input[idx])
        b = int(input[idx+1])
        t = float(input[idx+2])
        idx += 3
        
        if a == 0:
            inv_b = 1.0 / b
            ln_n = t ** inv_b
            n = math.exp(ln_n)
        elif b == 0:
            inv_a = 1.0 / a
            n = t ** inv_a
        else:
            c = math.log(t)
            # Find x_high by doubling until the value exceeds c
            x_high = 1.0
            while True:
                val = a * x_high + b * math.log(x_high)
                if val > c:
                    break
                x_high *= 2
            # Binary search between x_low and x_high
            x_low = 1e-10
            high = x_high
            low = x_low
            for _ in range(100):
                mid = (low + high) / 2
                val = a * mid + b * math.log(mid)
                if val < c:
                    low = mid
                else:
                    high = mid
            x = (low + high) / 2
            n = math.exp(x)
        # Print with 12 decimal places
        print("{0:.12f}".format(n))
        
if __name__ == "__main__":
    main()
0