結果

問題 No.2699 Simple Math (Returned)
ユーザー well-definedwell-defined
提出日時 2024-09-16 19:56:16
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 745 bytes
コンパイル時間 12,946 ms
コンパイル使用メモリ 379,384 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2024-09-16 19:56:36
合計ジャッジ時間 18,665 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 300 ms
5,248 KB
testcase_02 AC 320 ms
6,144 KB
testcase_03 AC 274 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 320 ms
5,888 KB
testcase_06 AC 299 ms
5,632 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn fast_pow_mod(mut base: u64, mut exp: u64, modulo: u64) -> u64 {
    if modulo == 1 { return 0; }
    let mut result = 1;
    base %= modulo;
    while exp > 0 {
        if exp % 2 == 1 {
            result = (result * base) % modulo;
        }
        exp /= 2;
        base = (base * base) % modulo;
    }
    result
}

fn main () {
    let modulo = 998244353;
    input! {
        t: u64,
    }
    for _ in 0..t {
        input! {
            n: u64,
            m: u64,
        }
        let n = n % (2*m);
        if n <= m {
            println!("{}", fast_pow_mod(10, n, modulo)-1);
        }
        else {
            println!("{}", fast_pow_mod(10, m, modulo)-fast_pow_mod(10, n-m, modulo))
        }

    }
}
0