QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#460383 | #8833. Equalizer Ehrmantraut | ucup-team3474 | WA | 0ms | 3656kb | C++23 | 572b | 2024-07-01 14:58:11 | 2024-07-01 14:58:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll;
const int N=1919810,mod=998244353;
ll n,m;
char s[N];
ll ksm(ll x,ll p){
ll sum=1,item=x;
while(p){
if(p&1) sum=sum*item%mod;
p>>=1;
item=item*item%mod;
}
return sum;
}
int main()
{
cin>>n>>m;
if(n==1){
cout<<m*m%mod<<endl;
}else{
ll ans=ksm(m,n);
ans*=(m-1);
ans%=mod;
ans%=mod;
ans-=ksm(m,n);
ans+=mod;
ans%=mod;
cout<<ans<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
1 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3656kb
input:
2 2
output:
0
result:
wrong answer 1st numbers differ - expected: '10', found: '0'