結果

問題 No.456 Millions of Submits!
ユーザー lam6er
提出日時 2025-03-31 17:43:53
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,455 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,772 KB
実行使用メモリ 293,184 KB
最終ジャッジ日時 2025-03-31 17:44:52
合計ジャッジ時間 11,526 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

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:
            # solve (ln n)^b = t
            if b == 0:
                # impossible per problem statement
                pass
            else:
                exponent = t ** (1.0 / b)
                n = math.exp(exponent)
        elif b == 0:
            # solve n^a = t
            n = t ** (1.0 / a)
        else:
            # a >0 and b >0
            low = 1.0
            high = 1.0
            # Find upper bound
            while True:
                log_high = math.log(high)
                f_high = (high ** a) * (log_high ** b)
                if f_high > t:
                    break
                high *= 2
            # Binary search
            for _ in range(100):
                mid = (low + high) / 2
                log_mid = math.log(mid)
                f_mid = (mid ** a) * (log_mid ** b)
                if f_mid < t:
                    low = mid
                else:
                    high = mid
            n = high
        
        # Format the output
        formatted = "{0:.12f}".format(n)
        if '.' in formatted:
            formatted = formatted.rstrip('0').rstrip('.')
        print(formatted)
        
if __name__ == '__main__':
    main()
0