結果

問題 No.456 Millions of Submits!
ユーザー titia
提出日時 2023-08-09 02:08:46
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2,125 ms / 4,500 ms
コード長 1,333 bytes
コンパイル時間 13,142 ms
コンパイル使用メモリ 389,036 KB
実行使用メモリ 82,944 KB
最終ジャッジ日時 2024-11-14 07:24:39
合計ジャッジ時間 23,644 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("Failed to read input");
    let q: usize = input.trim().parse().expect("Invalid input");

    let mut ans: Vec<f64> = vec![-1.0; q];

    for tests in 0..q {
        let mut input = String::new();
        io::stdin().read_line(&mut input).expect("Failed to read input");
        let mut numbers = input.split_whitespace().map(|s| s.parse::<f64>().expect("Invalid input"));

        let a: f64 = numbers.next().unwrap();
        let b: f64 = numbers.next().unwrap();
        let t: f64 = numbers.next().unwrap();

        if a == 0.0 {
            ans[tests] = f64::powf(2.718281828459045, f64::powf(t, 1.0 / b));
            continue;
        }

        if b == 0.0{
            ans[tests] = f64::powf(t, 1.0 / a);
            continue;

        }

        let mut max = 10.0;
        let mut min = 0.0;
        let epsilon = 1e-9;

        while max - min > epsilon {
            let mid = (max + min) / 2.0;

            if f64::powf(mid, a/b) * f64::ln(mid) > f64::powf(t, 1.0/b)  {
                max = mid;
            } else {
                min = mid;
            }
        }

        ans[tests] = (max + min) / 2.0;
    }

    println!("{}", ans.iter().map(|&x| x.to_string()).collect::<Vec<String>>().join("\n"));
}
0