QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#163634 | #6862. Card Game | jrjyy# | AC ✓ | 24ms | 3716kb | C++20 | 2.6kb | 2023-09-04 13:12:49 | 2023-09-04 13:12:49 |
Judging History
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