結果
問題 | No.1299 Random Array Score |
ユーザー |
|
提出日時 | 2022-02-06 22:29:30 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 1,723 bytes |
コンパイル時間 | 14,866 ms |
コンパイル使用メモリ | 377,608 KB |
実行使用メモリ | 5,632 KB |
最終ジャッジ日時 | 2024-06-11 14:32:29 |
合計ジャッジ時間 | 15,229 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#[macro_export]macro_rules! setup {{ mut $input:ident: SplitWhitespace $(,)? } => {use std::io::Read;let mut buf = String::new();std::io::stdin().read_to_string(&mut buf).ok();let mut $input = buf.split_whitespace();};}#[macro_export]macro_rules! parse_next {($str_iter:expr) => {$str_iter.next().unwrap().parse().ok().unwrap()};}#[allow(unused_imports)]use std::collections::{HashMap, HashSet, VecDeque};fn main() {setup! { mut input: SplitWhitespace };let n: usize = parse_next!(input);let k: usize = parse_next!(input);let a: Vec<usize> = (0..n).map(|_| parse_next!(input)).collect();const MOD: usize = 998244353;macro_rules! b {($i:expr, $op:tt, $j:expr) => {b!($i, $op, $j, MOD)};($i:expr, +, $j:expr, $mod:expr) => {($i + $j) % $mod};($i:expr, -, $j:expr, $mod:expr) => {{($i + $mod - $j) % $mod}};($i:expr, *, $j:expr, $mod:expr) => {($i * $j) % $mod};($i:expr, /, $j:expr, $mod:expr) => {b!($i, *, b!($j, ^, $mod - 2, $mod), $mod)};($i:expr, ^, $j:expr, $mod:expr) => {{let mut a = $i;let mut n = $j;let mut ret = 1;while n > 0 {if n & 1 == 1 {ret = b!(ret, *, a, $mod);}a = b!(a, *, a, $mod);n >>= 1;}ret}};}let ans = (|| {let sum = a.iter().fold(0, |acc, x| b!(acc, +, x));b!(sum, *, b!(2, ^, k))})();println!("{}", ans);}