結果

問題 No.2561 みんな大好きmod 998
コンテスト
ユーザー through
提出日時 2023-12-07 19:08:02
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 189 ms / 4,000 ms
+ 435µs
コード長 782 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 993 ms
コンパイル使用メモリ 192,960 KB
実行使用メモリ 9,732 KB
最終ジャッジ日時 2026-09-05 03:26:28
合計ジャッジ時間 5,251 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
#define rep(i, n) for(ll i = 0; i < n; i++)

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    ll n, k; cin >> n >> k;
    ll mod = 998;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> p;
    rep(i,k) p.emplace_back(1);
    while( p.size() < n ) p.emplace_back(0);
    sort(p.begin(), p.end());
    ll ans = 0;
    do {
        ll sum = 0;
        rep(i,n) if( p[i] ) sum += a[i];
        if( sum%998 >= sum%998244353 ) ans++;
    } while(next_permutation(p.begin(), p.end()));
    cout << ans%998 << endl;
    
    return 0;
}
0