QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#465225 | #8833. Equalizer Ehrmantraut | ucup-team3548# | AC ✓ | 70ms | 3728kb | C++20 | 3.1kb | 2024-07-06 19:04:40 | 2024-07-06 19:04:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
constexpr int N = 3e5 + 5;
const ll inf = 1e16;
template<class T>
T qpow(T a, ll b) {
T res = 1;
for (; b; b /= 2, a *= a) {
if (b % 2) {
res *= a;
}
}
return res;
}
const int P = 998244353;
struct Mint{
int x;
Mint() : x(0){}
Mint(int _x){
if(_x < 0)_x += P;
if(_x >= P)_x -= P;
x = _x;
}
Mint(ll _x) {
_x %= P;
if(_x < 0)_x += P;
x = _x;
}
int val() const {return x;}
int norm(int a){
if(a >= P) a -= P;
if(a < 0)a += P;
return a;
}
Mint inv() const{
// assert(x != 0);
return qpow(*this, P - 2);
}
Mint &operator+=(const Mint &a){
x += a.x;
if(x >= P)x -= P;
return *this;
}
Mint &operator-=(const Mint &a){
x -= a.x;
if(x < 0)x += P;
return *this;
}
Mint &operator*=(const Mint &a){x = 1ll * x * a.x % P; return *this;}
Mint &operator/=(const Mint &a){return *this *= a.inv();}
Mint &operator++(){x += 1; return *this;}
Mint operator++(int){Mint before(*this); x += 1; return before;}
Mint &operator--(){x -= 1; return *this;}
Mint operator--(int){Mint before(*this); x -= 1; return before;}
friend Mint operator+(const Mint &a, const Mint &b){
Mint res = a;
res += b;
return res;
}
friend Mint operator-(const Mint &a, const Mint &b){
Mint res = a;
res -= b;
return res;
}
friend Mint operator*(const Mint &a, const Mint &b){
Mint res = a;
res *= b;
return res;
}
friend Mint operator/(const Mint &a, const Mint &b){
Mint res = a;
res /= b;
return res;
}
Mint operator+() { return *this; }
Mint operator-() { return Mint(0) -= *this; }
friend bool operator==(const Mint &a, const Mint &b) { return a.x == b.x; }
friend bool operator!=(const Mint &a, const Mint &b) { return a.x != b.x; }
friend bool operator< (const Mint &a, const Mint &b) { return a.x < b.x; }
friend bool operator<=(const Mint &a, const Mint &b) { return a.x <= b.x; }
friend bool operator> (const Mint &a, const Mint &b) { return a.x > b.x; }
friend bool operator>=(const Mint &a, const Mint &b) { return a.x >= b.x; }
friend istream &operator>>(istream &is, Mint &a){
ll b;
cin >> b;
a = Mint(b);
return is;
}
friend ostream &operator<<(ostream &os, const Mint &a){
return os << a.val();
}
};
void solve(){
int n, m;
cin >> n >> m;
Mint ans = 2 * qpow<Mint> (m, n + 1) + qpow<Mint> (m, n);
for(int i = 1; i <= m; ++i){
ans -= 2 * qpow<Mint> (i, n);
}
cout << ans << '\n';
}
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
1 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
2 2
output:
10
result:
ok 1 number(s): "10"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
69 42
output:
608932821
result:
ok 1 number(s): "608932821"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
102 156
output:
748401290
result:
ok 1 number(s): "748401290"
Test #5:
score: 0
Accepted
time: 4ms
memory: 3604kb
input:
4646 95641
output:
89806680
result:
ok 1 number(s): "89806680"
Test #6:
score: 0
Accepted
time: 7ms
memory: 3604kb
input:
42849 215151
output:
242217237
result:
ok 1 number(s): "242217237"
Test #7:
score: 0
Accepted
time: 56ms
memory: 3684kb
input:
786416 794116
output:
472898000
result:
ok 1 number(s): "472898000"
Test #8:
score: 0
Accepted
time: 56ms
memory: 3676kb
input:
963852 789456
output:
353211048
result:
ok 1 number(s): "353211048"
Test #9:
score: 0
Accepted
time: 26ms
memory: 3608kb
input:
696969 424242
output:
787990158
result:
ok 1 number(s): "787990158"
Test #10:
score: 0
Accepted
time: 6ms
memory: 3604kb
input:
1000000 123456
output:
533491028
result:
ok 1 number(s): "533491028"
Test #11:
score: 0
Accepted
time: 70ms
memory: 3604kb
input:
1000000 1000000
output:
572586375
result:
ok 1 number(s): "572586375"
Test #12:
score: 0
Accepted
time: 58ms
memory: 3608kb
input:
123456 1000000
output:
486967129
result:
ok 1 number(s): "486967129"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
789456 1
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
852516 2
output:
148946358
result:
ok 1 number(s): "148946358"
Test #15:
score: 0
Accepted
time: 4ms
memory: 3680kb
input:
1 953646
output:
40087733
result:
ok 1 number(s): "40087733"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
3 7686
output:
278212472
result:
ok 1 number(s): "278212472"
Extra Test:
score: 0
Extra Test Passed