結果
| 問題 | No.2561 みんな大好きmod 998 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-12-02 15:05:38 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 274 ms / 4,000 ms | 
| コード長 | 825 bytes | 
| コンパイル時間 | 2,393 ms | 
| コンパイル使用メモリ | 180,564 KB | 
| 実行使用メモリ | 36,304 KB | 
| 最終ジャッジ日時 | 2024-09-26 18:01:43 | 
| 合計ジャッジ時間 | 6,788 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 44 | 
ソースコード
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/modint>
#include <atcoder/dsu>
#include <boost/rational.hpp>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
const double pi = 3.14159265359879323846264338327950288419;
const ll INF = 9 * 1e18;
using p = pair<ll, ll>;
int main() {
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<ll> tmp(n);
  for(int i = 0; i < k; i++) tmp[i]++;
  sort(tmp.begin(), tmp.end());
  
  vector<ll> v;
  do{
    ll sum = 0;
    for(int i = 0; i < n; i++){
      if(tmp[i]) sum += a[i];
    }
    v.push_back(sum);
  }while(next_permutation(tmp.begin(), tmp.end()));
  
  ll cnt = 0;
  for(auto x : v){
    if(x % 998244353 <= x % 998) cnt++;
  }
  
  cout << cnt % 998 << endl;
}
            
            
            
        