結果
| 問題 |
No.2699 Simple Math (Returned)
|
| コンテスト | |
| ユーザー |
well-defined
|
| 提出日時 | 2024-09-16 20:02:54 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
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));
}
}
}
well-defined