結果

問題 No.2561 みんな大好きmod 998
ユーザー ja14378ja14378
提出日時 2023-12-02 14:54:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 4,000 ms
コード長 969 bytes
コンパイル時間 4,484 ms
コンパイル使用メモリ 262,636 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 14:54:18
合計ジャッジ時間 6,478 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using ll = long long;
#define MOD 1000000007
#define Mod 998244353
const int MAX = 1000000005;
const long long INF = 1000000000000000005LL;
using namespace std;
using namespace atcoder;

int N, K, ans = 0;
void dfs(vector<int> &X, vector<int> &A) {
    if (X.size() == K) {
        ll S = 0;
        for (int i = 0; i < K; i++) S += A[X[i]];
        if (S % Mod <= S % 998) ans++;
        return;
    }
    if (X.size() == 0) {
        for (int i = 0; i < N; i++) {
            X.push_back(i);
            dfs(X, A);
            X.pop_back();
        }
    } else {
        for (int i = X[X.size() - 1]+1; i < N; i++) {
            X.push_back(i);
            dfs(X, A);
            X.pop_back();
        }
    }
}

int main() {
    ios::sync_with_stdio(0);cin.tie();
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<int> X;
    dfs(X, A);
    cout << ans % 998 << endl;
}
0