QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#460383#8833. Equalizer Ehrmantrautucup-team3474WA 0ms3656kbC++23572b2024-07-01 14:58:112024-07-01 14:58:11

Judging History

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

  • [2024-07-01 14:58:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3656kb
  • [2024-07-01 14:58:11]
  • 提交

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;
    }

}

详细

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'