結果

問題 No.219 巨大数の概算
ユーザー phsplsphspls
提出日時 2020-07-23 21:28:05
言語 Rust
(1.77.0)
結果
AC  
実行時間 26 ms / 1,500 ms
コード長 1,202 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 143,532 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 00:56:44
合計ジャッジ時間 5,983 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
4,376 KB
testcase_01 AC 24 ms
4,380 KB
testcase_02 AC 24 ms
4,380 KB
testcase_03 AC 24 ms
4,384 KB
testcase_04 AC 19 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 24 ms
4,380 KB
testcase_11 AC 25 ms
4,384 KB
testcase_12 AC 24 ms
4,376 KB
testcase_13 AC 24 ms
4,376 KB
testcase_14 AC 26 ms
4,376 KB
testcase_15 AC 24 ms
4,376 KB
testcase_16 AC 23 ms
4,376 KB
testcase_17 AC 22 ms
4,380 KB
testcase_18 AC 24 ms
4,380 KB
testcase_19 AC 22 ms
4,380 KB
testcase_20 AC 23 ms
4,380 KB
testcase_21 AC 23 ms
4,380 KB
testcase_22 AC 22 ms
4,376 KB
testcase_23 AC 24 ms
4,376 KB
testcase_24 AC 24 ms
4,380 KB
testcase_25 AC 25 ms
4,380 KB
testcase_26 AC 24 ms
4,380 KB
testcase_27 AC 24 ms
4,380 KB
testcase_28 AC 24 ms
4,376 KB
testcase_29 AC 25 ms
4,380 KB
testcase_30 AC 24 ms
4,380 KB
testcase_31 AC 24 ms
4,380 KB
testcase_32 AC 23 ms
4,376 KB
testcase_33 AC 24 ms
4,376 KB
testcase_34 AC 24 ms
4,380 KB
testcase_35 AC 23 ms
4,376 KB
testcase_36 AC 22 ms
4,380 KB
testcase_37 AC 23 ms
4,380 KB
testcase_38 AC 24 ms
4,380 KB
testcase_39 AC 23 ms
4,380 KB
testcase_40 AC 23 ms
4,376 KB
testcase_41 AC 25 ms
4,376 KB
testcase_42 AC 23 ms
4,380 KB
testcase_43 AC 24 ms
4,376 KB
testcase_44 AC 24 ms
4,380 KB
testcase_45 AC 23 ms
4,376 KB
testcase_46 AC 24 ms
4,376 KB
testcase_47 AC 24 ms
4,380 KB
testcase_48 AC 23 ms
4,376 KB
testcase_49 AC 24 ms
4,380 KB
testcase_50 AC 23 ms
4,380 KB
testcase_51 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn calc(ranks: &mut usize, mul: f64, depth: &mut usize, times: usize) -> f64 {
    if times == 0 { return 1.0f64; }
    if times == 1 { return mul; }
    *depth += 1;
    let mut temp = calc(ranks, mul, depth, times / 2);
    temp = temp * temp * calc(ranks, mul, depth, times % 2);
    if temp >= 100.0f64 { *ranks += 2usize.pow(*depth as u32); temp /= 100.0f64; }
    if temp >= 10.0f64 { *ranks += 2usize.pow(*depth as u32 - 1); temp /= 10.0f64; }
    *depth -= 1;
    temp
}

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    for _ in 0..n {
        let mut ab = String::new();
        std::io::stdin().read_line(&mut ab).ok();
        let ab: Vec<usize> = ab.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let mut a = ab[0] as f64;
        let b = ab[1];
        let mut rank: usize = 0;
        while a >= 10.0f64 {
            a /= 10.0f64;
            rank += 1;
        }
        rank *= b;
        let mut depth: usize = 0;
        let result = calc(&mut rank, a, &mut depth, b);
        println!("{} {} {}", result as usize , (result * 10f64) as usize % 10usize, rank);
    }
}
0