結果

問題 No.2561 みんな大好きmod 998
ユーザー tenbatenba
提出日時 2023-12-02 15:07:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,461 ms / 4,000 ms
コード長 2,604 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 121,612 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 15:08:15
合計ジャッジ時間 20,568 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 18 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1,461 ms
6,676 KB
testcase_04 AC 1,456 ms
6,676 KB
testcase_05 AC 1,457 ms
6,676 KB
testcase_06 AC 1,461 ms
6,676 KB
testcase_07 AC 162 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 187 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 37 ms
6,676 KB
testcase_14 AC 72 ms
6,676 KB
testcase_15 AC 1,454 ms
6,676 KB
testcase_16 AC 140 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 3 ms
6,676 KB
testcase_19 AC 778 ms
6,676 KB
testcase_20 AC 11 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 342 ms
6,676 KB
testcase_27 AC 1,456 ms
6,676 KB
testcase_28 AC 647 ms
6,676 KB
testcase_29 AC 58 ms
6,676 KB
testcase_30 AC 144 ms
6,676 KB
testcase_31 AC 438 ms
6,676 KB
testcase_32 AC 1,174 ms
6,676 KB
testcase_33 AC 58 ms
6,676 KB
testcase_34 AC 1,457 ms
6,676 KB
testcase_35 AC 302 ms
6,676 KB
testcase_36 AC 300 ms
6,676 KB
testcase_37 AC 45 ms
6,676 KB
testcase_38 AC 187 ms
6,676 KB
testcase_39 AC 144 ms
6,676 KB
testcase_40 AC 144 ms
6,676 KB
testcase_41 AC 189 ms
6,676 KB
testcase_42 AC 661 ms
6,676 KB
testcase_43 AC 46 ms
6,676 KB
testcase_44 AC 103 ms
6,676 KB
testcase_45 AC 800 ms
6,676 KB
testcase_46 AC 584 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define SZ(x) ((int)(x).size());
#define vec vector
template <class T>
using v = vector<T>;
template <class T>
using vv = v< v<T> >;
template <class T>
using vvv = v< vv<T> >;
#define el '\n'
#define vl v<ll>
#define vvl vv<ll>
#define pl pair<ll, ll>
#define repab(i, a, b) for(ll i = a; a < (ll)(b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define rep1(i, n) for(ll i = 1; i <= (ll)(n); ++i)
#define rrep(i, n) for(ll i = ((ll)(n) - 1); i >= 0; --i)
#define rrep1(i, n) for(ll i = ((ll)(n)); i > 0; --i)
#define YN(x) cout << ((x) ? "YES\n" : "NO\n");
#define Yn(x) cout << ((x) ? "Yes\n" : "No\n");
#define yn(x) cout << ((x) ? "yes\n" : "no\n");
#define COUT(x) cout << (x) << el;
const double pi = 3.141592653589793238;
const int inf = 1073741823;
const ll infl = 1LL << 60;

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    int n,k;
    cin >> n >> k;
    vector<long long> a(n);
    const long long mod = 998244353;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    long long count = 0;
    for(long long i = 0; i < (1 << n); ++i){
        long long mod998 = 0;
        long long mod998244353 = 0;
        if(bitset<28>(i).count() != k) continue;
        for(long long j = 0; j < n; ++j){
            if(i & (1 << j)){
                mod998 += (a[j] % 998);
                mod998 %= 998;
                mod998244353 += a[j];
                mod998244353 %= 998244353;
            }
        }
        if(mod998244353 <= mod998){
            count++;
            count %= 998;
        }
    }
    cout << count << endl;

    return 0;
}
0