QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#228541 | #7632. Balanced Arrays | ucup-team1074# | WA | 2ms | 1604kb | C++98 | 647b | 2023-10-28 13:41:14 | 2023-10-28 13:41:14 |
Judging History
answer
#include<cstdio>
using namespace std;
long long int mod(long long int x){
return x%998244353;
}
long long int n,m;
long long int ans=0;
long long int po(long long int x,long long int i){
if(i==1)return mod(x);
if(i==2)return mod(mod(x)*mod(x));
if(i%2==0){
long long int t=mod(po(x,i/2));
return mod(t*t);
}
else{
long long int t=mod(po(x,i/2));
return mod(mod(t*t)*mod(x));
}
}
int main(){
long long int x=0;
scanf("%lld%lld",&n,&m);
if(m==0){
printf("1\n");
return 0;
}
for(long long int i=1;i<=n;i++){
x+=i*(n-i+1);
x=mod(x);
}
x-=1;
printf("%lld\n",po(x,m));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1604kb
input:
2 2
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 1588kb
input:
500000 500000
output:
638345879
result:
wrong answer 1st numbers differ - expected: '984531374', found: '638345879'