結果

問題 No.2561 みんな大好きmod 998
ユーザー neko_the_shadowneko_the_shadow
提出日時 2024-02-16 15:14:17
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 973 bytes
コンパイル時間 10,692 ms
コンパイル使用メモリ 166,144 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-16 15:14:40
合計ジャッジ時間 7,834 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 WA -
testcase_02 AC 1 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 346 ms
6,676 KB
testcase_05 WA -
testcase_06 AC 350 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 51 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 347 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 248 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 1 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 1 ms
6,676 KB
testcase_26 AC 70 ms
6,676 KB
testcase_27 AC 352 ms
6,676 KB
testcase_28 AC 95 ms
6,676 KB
testcase_29 AC 25 ms
6,676 KB
testcase_30 AC 78 ms
6,676 KB
testcase_31 AC 171 ms
6,676 KB
testcase_32 AC 41 ms
6,676 KB
testcase_33 AC 26 ms
6,676 KB
testcase_34 AC 345 ms
6,676 KB
testcase_35 AC 24 ms
6,676 KB
testcase_36 AC 24 ms
6,676 KB
testcase_37 AC 11 ms
6,676 KB
testcase_38 AC 52 ms
6,676 KB
testcase_39 AC 79 ms
6,676 KB
testcase_40 AC 78 ms
6,676 KB
testcase_41 AC 51 ms
6,676 KB
testcase_42 AC 97 ms
6,676 KB
testcase_43 AC 10 ms
6,676 KB
testcase_44 AC 36 ms
6,676 KB
testcase_45 AC 244 ms
6,676 KB
testcase_46 AC 31 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::stdin;

fn main() {
    let nk = read();
    let n = nk[0];
    let k = nk[1];
    let a = read();

    // bit, cur, tot
    let mut c = 0;
    let mut stack = (0..n).map(|i| (1i128<<i, i, 1)).collect::<Vec<_>>();
    while !stack.is_empty() {
        let (bit, cur, tot) = stack.pop().unwrap();
        if tot==k {
            let mut t1 = 0;
            let mut t2 = 0;
            for i in 0..n {
                if bit&(1<<i)!=0 {
                    t1 = (t1+a[i])%998;
                    t2 = (t2+a[i])%998244352;
                }
            }
            if t2<=t1 {
                c += 1;
            }
            continue;
        }
        for nxt in cur+1..n {
            stack.push((bit|(1<<nxt), nxt, tot+1));
        }
    }
    println!("{}", c);
}

fn read() -> Vec<usize> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.split_whitespace().map(|token| token.parse().unwrap()).collect::<Vec<_>>()
}
0