結果
| 問題 | No.2561 みんな大好きmod 998 | 
| コンテスト | |
| ユーザー |  umezo | 
| 提出日時 | 2023-12-02 15:01:19 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 413 ms / 4,000 ms | 
| コード長 | 590 bytes | 
| コンパイル時間 | 2,005 ms | 
| コンパイル使用メモリ | 194,248 KB | 
| 最終ジャッジ日時 | 2025-02-18 04:09:11 | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 44 | 
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n,k;
  cin>>n>>k;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  int ans=0;
  for (int x = (1 << k) - 1; x < (1 << n); ) {
     ll sum=0;
    rep(j,n){
      if(x&(1<<j)) sum+=A[j];
    }
    if(sum%998>=sum%998244353) ans++;
    
    int t = x | (x - 1);
    x = (t + 1) | (((~ t & - ~ t) - 1) >> (__builtin_ctz(x) + 1));
  }
  cout<<ans%998<<endl;
    
  return 0;
}
            
            
            
        