結果

問題 No.2699 Simple Math (Returned)
ユーザー well-definedwell-defined
提出日時 2024-09-16 20:02:54
言語 Rust
(1.77.0)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 12,519 ms
コンパイル使用メモリ 401,764 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-09-16 20:03:16
合計ジャッジ時間 18,641 ms
ジャッジサーバーID
(参考情報)
judge6 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 277 ms
5,248 KB
testcase_02 AC 323 ms
6,016 KB
testcase_03 AC 273 ms
5,376 KB
testcase_04 AC 356 ms
6,016 KB
testcase_05 AC 309 ms
5,760 KB
testcase_06 AC 300 ms
5,760 KB
testcase_07 AC 342 ms
5,760 KB
testcase_08 AC 332 ms
5,888 KB
testcase_09 AC 335 ms
5,760 KB
testcase_10 AC 339 ms
5,760 KB
testcase_11 AC 335 ms
5,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn fast_pow_mod(mut base: i64, mut exp: i64, modulo: i64) -> i64 {
    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: usize,
    }
    for _ in 0..t {
        input! {
            n: i64,
            m: i64,
        }
        let n = n % (2*m);

        if n <= m {
            println!("{}", (fast_pow_mod(10, n, modulo)-1).rem_euclid(modulo));
        }
        else {
            println!("{}", (fast_pow_mod(10, m, modulo)-fast_pow_mod(10, n-m, modulo)).rem_euclid(modulo));
        }

    }
}
0