QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#163634#6862. Card Gamejrjyy#AC ✓24ms3716kbC++202.6kb2023-09-04 13:12:492023-09-04 13:12:49

Judging History

你现在查看的是最新测评结果

  • [2023-09-04 13:12:49]
  • 评测
  • 测评结果:AC
  • 用时:24ms
  • 内存:3716kb
  • [2023-09-04 13:12:49]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

template <typename T> constexpr T power(T a, i64 b) {
    T c{1}; for (; b; b /= 2, a *= a) if (b & 1) c *= a;
    return c;
}
template <int P> struct MInt {
    int x;
    constexpr MInt() : x{} {}
    constexpr MInt(i64 x_) : x{norm(x_ % getMod())} {}
    static int Mod;
    constexpr static int getMod() { return P > 0 ? P : Mod; }
    constexpr static void setMod(int Mod_) { Mod = Mod_; }
    constexpr int up(int x) const {
        if (x < 0) x += getMod();
        return x;
    }
    constexpr int down(int x) const {
        if (x >= getMod()) x -= getMod();
        return x;
    }
    constexpr int norm(int x) const {
        return up(down(x));
    }
    constexpr int val() const { return x; }
    explicit constexpr operator int() const { return x; }
    constexpr MInt operator-() const {
        MInt res; res.x = norm(getMod() - x); return res;
    }
    constexpr MInt inv() const {
        assert(x != 0);
        return power(*this, getMod() - 2);
    }
    constexpr MInt &operator+=(MInt rhs) & { return x = down(x + rhs.x), *this; }
    constexpr MInt &operator-=(MInt rhs) & { return x = up(x - rhs.x), *this; }
    constexpr MInt &operator*=(MInt rhs) & { return x = 1ll * x * rhs.x % getMod(), *this; }
    constexpr MInt &operator/=(MInt rhs) & { return *this *= rhs.inv(); }
    friend constexpr MInt operator+(MInt lhs, MInt rhs) { return lhs += rhs; }
    friend constexpr MInt operator-(MInt lhs, MInt rhs) { return lhs -= rhs; }
    friend constexpr MInt operator*(MInt lhs, MInt rhs) { return lhs *= rhs; }
    friend constexpr MInt operator/(MInt lhs, MInt rhs) { return lhs /= rhs; }
    friend constexpr bool operator==(MInt lhs, MInt rhs) { return lhs.val() == rhs.val(); }
    friend constexpr bool operator!=(MInt lhs, MInt rhs) { return lhs.val() != rhs.val(); }
    friend constexpr std::istream &operator>>(std::istream &is, MInt &a) {
        i64 x = 0; is >> x, a = MInt(x); return is;
    }
    friend constexpr std::ostream &operator<<(std::ostream &os, const MInt &a) {
        return os << a.val();
    }
};

template <int P> int MInt<P>::Mod = P;
template <> int MInt<0>::Mod = 1;
template <int V, int P> constexpr MInt<P> CInv = MInt<P>(V).inv();

constexpr int P = 998244353;
using Z = MInt<P>;

void solve() {
    int n;
    std::cin >> n;

    std::cout << power(Z(2), n - 1) - 1 << '\n';
}

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 24ms
memory: 3716kb

input:

100000
2
3
114514
981241785
906230829
381983545
603202994
197057696
698550046
686442509
236903653
182548925
796382933
494249966
776943392
816288818
177783961
452280571
699889611
628394197
777548138
700770875
273071548
599075146
752655475
431260929
469058558
261214299
95047810
28129680
424043074
7484...

output:

1
3
766171354
160324165
564652108
77463044
103890294
408092449
664371344
584887977
905113776
859047215
139494947
136318741
84616732
631127780
510826448
913548747
170568691
71726375
508582189
302917162
236873016
226078926
260542513
123521882
329333027
811061366
222648645
465369296
608057020
152577004...

result:

ok 100000 lines