結果

問題 No.2561 みんな大好きmod 998
ユーザー Feishi LiFeishi Li
提出日時 2023-12-02 15:23:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 415 ms / 4,000 ms
コード長 2,720 bytes
コンパイル時間 4,496 ms
コンパイル使用メモリ 265,796 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 15:23:46
合計ジャッジ時間 10,383 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 17 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 415 ms
6,676 KB
testcase_04 AC 410 ms
6,676 KB
testcase_05 AC 407 ms
6,676 KB
testcase_06 AC 407 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 61 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 409 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 287 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 3 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 85 ms
6,676 KB
testcase_27 AC 407 ms
6,676 KB
testcase_28 AC 110 ms
6,676 KB
testcase_29 AC 31 ms
6,676 KB
testcase_30 AC 91 ms
6,676 KB
testcase_31 AC 202 ms
6,676 KB
testcase_32 AC 50 ms
6,676 KB
testcase_33 AC 31 ms
6,676 KB
testcase_34 AC 407 ms
6,676 KB
testcase_35 AC 30 ms
6,676 KB
testcase_36 AC 31 ms
6,676 KB
testcase_37 AC 13 ms
6,676 KB
testcase_38 AC 62 ms
6,676 KB
testcase_39 AC 90 ms
6,676 KB
testcase_40 AC 91 ms
6,676 KB
testcase_41 AC 61 ms
6,676 KB
testcase_42 AC 111 ms
6,676 KB
testcase_43 AC 15 ms
6,676 KB
testcase_44 AC 44 ms
6,676 KB
testcase_45 AC 288 ms
6,676 KB
testcase_46 AC 39 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <bits/extc++.h>
using i64 = long long;
template <typename T, T MOD = 1000000007>
struct Mint
{
    inline static constexpr T mod = MOD;
    T v;
    Mint() : v(0) {}
    Mint(signed v) : v(v) {}
    Mint(long long t)
    {
        v = t % MOD;
        if (v < 0)
            v += MOD;
    }

    Mint pow(long long k)
    {
        Mint res(1), tmp(v);
        while (k)
        {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }

    static Mint add_identity() { return Mint(0); }
    static Mint mul_identity() { return Mint(1); }

    Mint inv() { return pow(MOD - 2); }

    Mint &operator+=(Mint a)
    {
        v += a.v;
        if (v >= MOD)
            v -= MOD;
        return *this;
    }
    Mint &operator-=(Mint a)
    {
        v += MOD - a.v;
        if (v >= MOD)
            v -= MOD;
        return *this;
    }
    Mint &operator*=(Mint a)
    {
        v = 1LL * v * a.v % MOD;
        return *this;
    }
    Mint &operator/=(Mint a) { return (*this) *= a.inv(); }

    Mint operator+(Mint a) const { return Mint(v) += a; }
    Mint operator-(Mint a) const { return Mint(v) -= a; }
    Mint operator*(Mint a) const { return Mint(v) *= a; }
    Mint operator/(Mint a) const { return Mint(v) /= a; }

    Mint operator+() const { return *this; }
    Mint operator-() const { return v ? Mint(MOD - v) : Mint(v); }

    bool operator==(const Mint a) const { return v == a.v; }
    bool operator!=(const Mint a) const { return v != a.v; }

    static Mint comb(long long n, int k)
    {
        Mint num(1), dom(1);
        for (int i = 0; i < k; i++)
        {
            num *= Mint(n - i);
            dom *= Mint(i + 1);
        }
        return num / dom;
    }
};
template <typename T, T MOD>
std::ostream &operator<<(std::ostream &os, Mint<T, MOD> m)
{
    os << m.v;
    return os;
}
using Z1 = Mint<i64, 998>;
using Z2 = Mint<i64, 998244353>;
void solve()
{
    int n, k;
    std::cin >> n >> k;
    std::vector<i64> a(n);
    std::vector<bool> use(n);
    for (auto &i : a)
    {
        std::cin >> i;
    }
    std::fill(use.begin(), use.begin() + k, true);

    Z1 ans = 0;

    do
    {
        Z1 S1 = 0;
        Z2 S2 = 0;
        for (int i = 0; i < n; i++)
        {
            if (!use[i])
                continue;
            S1 += a[i];
            S2 += a[i];
        }
        i64 ans1 = S1.v, ans2 = S2.v;
        if (ans2 <= ans1)
        {
            ans += 1;
        }
    } while (std::prev_permutation(use.begin(), use.end()));
    std::cout << ans << '\n';
}
int main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    solve();
    return 0;
}
0