75分求助,最后一个点T了
查看原帖
75分求助,最后一个点T了
1399125
ja_Spectre楼主2025/1/5 10:13
#include <cstdio>
#include<iostream>
#include <cmath> 
using namespace std;
long long M=998244353;
long long a[1000005];
long long pow(long long a,long long b)
{
	if(b==0) return 1;
	if(b%2==1) return a*pow(a,b-1)%M;
	else 
	{
		long long temp=pow(a,b/2)%M;
	    return (temp*temp)%M;
	}
}
int main()
{
long long n,p;
long long result = 1;
scanf("%lld%lld",&n,&p);
for (int i=0;i<n;++i){
	scanf("%lld",&a[i]);
}
for (int i=0;i<n;++i){
	result *= pow(p,a[i])%M+1;
	result%=M;
}
printf("%lld",result%M);
	return 0; 
}


2025/1/5 10:13
加载中...