QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#600248 | #8833. Equalizer Ehrmantraut | xydCatGirl# | AC ✓ | 157ms | 3708kb | C++14 | 2.1kb | 2024-09-29 15:30:12 | 2024-09-29 15:30:14 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
constexpr int N = 1e6 + 5, P = 998244353;
template<typename T>
T power(T a, i64 b) {
T ret = 1;
while (b) {
if (b & 1) ret = ret * a;
a = a * a;
b >>= 1;
}
return ret;
}
template<int P>
struct ModInt {
int val;
static inline int norm(int x) {
if (x < 0) x += P;
if (x >= P) x -= P;
return x;
}
ModInt operator - () const { return ModInt(P - val); }
inline ModInt inv() const { return power(*this, P - 2); }
ModInt() {}
ModInt(int val) : val(norm(val % P)) {}
ModInt(i64 val) : val(norm(val % P)) {}
bool constexpr operator < (const ModInt &rhs) const { return val < rhs.val; }
bool constexpr operator == (const ModInt &rhs) const { return val == rhs.val; }
bool constexpr operator != (const ModInt &rhs) const { return val != rhs.val; }
ModInt &operator += (const ModInt &rhs) & { return val = norm(val + rhs.val), *this; }
ModInt &operator -= (const ModInt &rhs) & { return val = norm(val - rhs.val), *this; }
ModInt &operator *= (const ModInt &rhs) & { return val = 1ll * val * rhs.val % P, *this; }
ModInt &operator /= (const ModInt &rhs) & { return *this *= rhs.inv(); }
ModInt constexpr operator + (const ModInt &rhs) const { ModInt ret = *this; return ret += rhs; }
ModInt constexpr operator - (const ModInt &rhs) const { ModInt ret = *this; return ret -= rhs; }
ModInt constexpr operator * (const ModInt &rhs) const { ModInt ret = *this; return ret *= rhs; }
ModInt constexpr operator / (const ModInt &rhs) const { ModInt ret = *this; return ret /= rhs; }
friend std::istream& operator >> (std::istream& is, ModInt &rhs) {
i64 val; is >> val;
return rhs.val = norm(val % P), is;
}
friend constexpr std::ostream& operator << (std::ostream& os, const ModInt &rhs) {
return os << rhs.val;
}
};
using Z = ModInt<P>;
int n, m;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin >> n >> m;
Z ans = 0;
for (int x = 1; x <= m; x++) ans += power(Z(m), n) - power(Z(x), n);
std::cout << ans * 2 + power(Z(m), n) << "\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
1 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
2 2
output:
10
result:
ok 1 number(s): "10"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
69 42
output:
608932821
result:
ok 1 number(s): "608932821"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
102 156
output:
748401290
result:
ok 1 number(s): "748401290"
Test #5:
score: 0
Accepted
time: 9ms
memory: 3708kb
input:
4646 95641
output:
89806680
result:
ok 1 number(s): "89806680"
Test #6:
score: 0
Accepted
time: 25ms
memory: 3552kb
input:
42849 215151
output:
242217237
result:
ok 1 number(s): "242217237"
Test #7:
score: 0
Accepted
time: 121ms
memory: 3596kb
input:
786416 794116
output:
472898000
result:
ok 1 number(s): "472898000"
Test #8:
score: 0
Accepted
time: 122ms
memory: 3656kb
input:
963852 789456
output:
353211048
result:
ok 1 number(s): "353211048"
Test #9:
score: 0
Accepted
time: 63ms
memory: 3632kb
input:
696969 424242
output:
787990158
result:
ok 1 number(s): "787990158"
Test #10:
score: 0
Accepted
time: 15ms
memory: 3548kb
input:
1000000 123456
output:
533491028
result:
ok 1 number(s): "533491028"
Test #11:
score: 0
Accepted
time: 157ms
memory: 3660kb
input:
1000000 1000000
output:
572586375
result:
ok 1 number(s): "572586375"
Test #12:
score: 0
Accepted
time: 124ms
memory: 3640kb
input:
123456 1000000
output:
486967129
result:
ok 1 number(s): "486967129"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
789456 1
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
852516 2
output:
148946358
result:
ok 1 number(s): "148946358"
Test #15:
score: 0
Accepted
time: 6ms
memory: 3628kb
input:
1 953646
output:
40087733
result:
ok 1 number(s): "40087733"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
3 7686
output:
278212472
result:
ok 1 number(s): "278212472"
Extra Test:
score: 0
Extra Test Passed