結果

問題 No.2561 みんな大好きmod 998
ユーザー GOTKAKO
提出日時 2023-12-02 14:41:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 4,000 ms
コード長 553 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 198,124 KB
最終ジャッジ日時 2025-02-18 03:47:33
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    long long N,K; cin >> N >> K;
    vector<long long> A(N);
    for(auto &a : A) cin >> a;

    long long answer = 0;
auto dfs = [&](auto dfs,int pos,int pick,long long sum) -> void {
    if(pick == K){
        if(sum%998244353 <= sum%998) answer++;
        return;
    }
    if(pos == N) return;

    for(int i=pos; i<N; i++){
        dfs(dfs,i+1,pick+1,sum+A.at(i));
    }
};
    dfs(dfs,0,0,0);
    cout << answer%998 << endl;
}
0