結果
問題 | No.1299 Random Array Score |
ユーザー |
![]() |
提出日時 | 2020-12-11 17:53:43 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 957 bytes |
コンパイル時間 | 11,605 ms |
コンパイル使用メモリ | 377,868 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-19 21:25:33 |
合計ジャッジ時間 | 13,632 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 31 |
コンパイルメッセージ
warning: unused import: `std::cmp::*` --> src/main.rs:3:5 | 3 | use std::cmp::*; | ^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused import: `std::collections::*` --> src/main.rs:4:5 | 4 | use std::collections::*; | ^^^^^^^^^^^^^^^^^^^ warning: variable does not need to be mutable --> src/main.rs:23:9 | 23 | let mut k:u64 = read(); | ----^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default warning: variable does not need to be mutable --> src/main.rs:24:9 | 24 | let mut a:Vec<u64> = (0..n).map(|_| read()).collect(); | ----^ | | | help: remove this `mut` warning: variable does not need to be mutable --> src/main.rs:25:9 | 25 | let mut f:u64 = a.into_iter().sum(); | ----^ | | | help: remove this `mut` warning: constant `Mod` should have an upper case name --> src/main.rs:20:7 | 20 | const Mod:u64 = 998244353; | ^^^ help: convert the identifier to upper case: `MOD` | = note: `#[warn(non_upper_case_globals)]` on by default
ソースコード
#[allow(unused_imports)] use proconio::*; use std::cmp::*; use std::collections::*; use std::io::*; use std::iter::*; use std::str::FromStr; fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } const Mod:u64 = 998244353; fn main() { let n:usize = read(); let mut k:u64 = read(); let mut a:Vec<u64> = (0..n).map(|_| read()).collect(); let mut f:u64 = a.into_iter().sum(); println!("{}",(rep_mul(2u64,k) * f) % Mod); } fn rep_mul(mut x: u64, mut n: u64) -> u64{ let mut ans:u64 = 1; while n > 0{ if n % 2 == 1 { ans = x * ans % Mod; } x = x * x % Mod; n = n >> 1u64; } ans }