結果

問題 No.897 compαctree
ユーザー akakimidoriakakimidori
提出日時 2019-10-04 21:23:52
言語 Rust
(1.72.1)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 1,479 ms
コンパイル使用メモリ 144,808 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-26 20:41:01
合計ジャッジ時間 2,265 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let q: usize = it.next().unwrap().parse().unwrap();
    for _ in 0..q {
        let n: usize = it.next().unwrap().parse().unwrap();
        let k: usize = it.next().unwrap().parse().unwrap();
        if k == 1 {
            println!("{}", n - k);
            continue;
        }
        let mut sum = 1;
        let mut d = k;
        let mut ans = 0;
        while sum < n {
            ans += 1;
            sum += d;
            d *= k;
        }
        println!("{}", ans);
    }
}

fn main() {
    run();
}
0