結果

問題 No.1299 Random Array Score
ユーザー uw_yu1rabbituw_yu1rabbit
提出日時 2020-12-11 17:54:19
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 959 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 180,340 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 01:36:26
合計ジャッジ時間 2,894 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 18 ms
4,348 KB
testcase_35 AC 46 ms
4,348 KB
testcase_36 AC 18 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::collections::*`
 --> Main.rs:4:5
  |
4 | use std::collections::*;
  |     ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: variable does not need to be mutable
  --> 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
  --> 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
  --> 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
  --> 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

warning: 5 warnings emitted

ソースコード

diff #

#[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
}
0