結果
| 問題 | No.2561 みんな大好きmod 998 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-12-02 14:42:50 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 269 ms / 4,000 ms | 
| コード長 | 868 bytes | 
| コンパイル時間 | 2,181 ms | 
| コンパイル使用メモリ | 196,336 KB | 
| 最終ジャッジ日時 | 2025-02-18 03:50:26 | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 44 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, ans = 0;;
    cin >> n >> k;
    vector<ll> a(n);
    cin >> a;
    for(int comb = (1 << k) - 1; comb < (1 << n); ){
        ll s = 0;
        for(int i = 0; i < n; i++){
            if(comb >> i & 1) s += a[i];
        }
        ans += (s % 998 >= s % 998244353);
        int x = comb & (-comb), y = comb + x;
        comb = ((comb & ~y) / x >> 1) | y;
    }
    cout << ans % 998 << '\n';
}
            
            
            
        