結果

問題 No.2561 みんな大好きmod 998
ユーザー 👑 KA37RIKA37RI
提出日時 2023-12-02 15:30:46
言語 Rust
(1.77.0)
結果
AC  
実行時間 73 ms / 4,000 ms
コード長 1,019 bytes
コンパイル時間 1,949 ms
コンパイル使用メモリ 182,520 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 15:30:50
合計ジャッジ時間 3,073 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 5 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 70 ms
6,548 KB
testcase_04 AC 69 ms
6,548 KB
testcase_05 AC 73 ms
6,548 KB
testcase_06 AC 71 ms
6,548 KB
testcase_07 AC 1 ms
6,548 KB
testcase_08 AC 0 ms
6,548 KB
testcase_09 AC 1 ms
6,548 KB
testcase_10 AC 1 ms
6,548 KB
testcase_11 AC 11 ms
6,548 KB
testcase_12 AC 1 ms
6,548 KB
testcase_13 AC 1 ms
6,548 KB
testcase_14 AC 1 ms
6,548 KB
testcase_15 AC 70 ms
6,548 KB
testcase_16 AC 1 ms
6,548 KB
testcase_17 AC 1 ms
6,548 KB
testcase_18 AC 1 ms
6,548 KB
testcase_19 AC 49 ms
6,548 KB
testcase_20 AC 1 ms
6,548 KB
testcase_21 AC 1 ms
6,548 KB
testcase_22 AC 1 ms
6,548 KB
testcase_23 AC 0 ms
6,548 KB
testcase_24 AC 1 ms
6,548 KB
testcase_25 AC 1 ms
6,548 KB
testcase_26 AC 15 ms
6,548 KB
testcase_27 AC 71 ms
6,548 KB
testcase_28 AC 18 ms
6,548 KB
testcase_29 AC 6 ms
6,548 KB
testcase_30 AC 17 ms
6,548 KB
testcase_31 AC 36 ms
6,548 KB
testcase_32 AC 8 ms
6,548 KB
testcase_33 AC 6 ms
6,548 KB
testcase_34 AC 68 ms
6,548 KB
testcase_35 AC 5 ms
6,548 KB
testcase_36 AC 5 ms
6,548 KB
testcase_37 AC 3 ms
6,548 KB
testcase_38 AC 10 ms
6,548 KB
testcase_39 AC 17 ms
6,548 KB
testcase_40 AC 18 ms
6,548 KB
testcase_41 AC 10 ms
6,548 KB
testcase_42 AC 18 ms
6,548 KB
testcase_43 AC 2 ms
6,548 KB
testcase_44 AC 7 ms
6,548 KB
testcase_45 AC 53 ms
6,548 KB
testcase_46 AC 6 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
  let nk = input();
  let mut nk = nk.split(' '); 
  let n: usize = nk.next().unwrap().parse().unwrap();
  let k: usize = nk.next().unwrap().parse().unwrap();
  let a = input();
  let a: Vec<usize> = a.split(' ').map(|ai| ai.parse().unwrap()).collect();

  let mut stack = Vec::new();
  let mut s = vec![0; k];
  let mut ans = 0usize;
  for p in 0..n {
    stack.push((false, 0, 0));
    stack.push((true, 0, p));
  }
  while let Some((cf, ci, cx)) = stack.pop() {
    if cf {
      s[ci] = cx;
      if ci == k - 1 {
        let sm: usize = s.iter().map(|&xi| a[xi]).sum();
        if sm % 998244353 <= sm % 998 {
          ans += 1;
        }
      }else {
        for nx in cx+1..n {
          stack.push((false, ci + 1, 0));
          stack.push((true, ci + 1, nx));
        }
      }
    }else {
      s[ci] = 0;
    }
  }
  println!("{}", ans % 998);
}

fn input() -> String {
  let mut buffer = String::new();
  std::io::stdin().read_line(&mut buffer).unwrap();
  return buffer.trim().to_string();
}
0