Educational Codeforces Round 52 (Rated for Div. 2) E. Side Transmutations

时间:2023-01-27 06:07:24

http://codeforces.com/contest/1065/problem/E

数学推导题

 #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define nl 2.7182818284
const ll mod=;
const int maxn=1e5+; ll mul(ll a,ll b)
{
ll y=;
while (b)
{
if (b & )
y=y*a%mod;
b>>=;
a=a*a%mod;
}
return y;
} int main()
{
int n,m,g,b,preb,len,i;
ll sum=,v;
scanf("%d%d%d",&n,&m,&g);
preb=;
for (i=;i<=m;i++)
{
scanf("%d",&b);
len=b-preb;
v=mul(g,len);
sum=(sum*v%mod*(v+)%mod*)%mod;
preb=b;
}
v=mul(g,n-*b);
sum=sum*v%mod;
cout<<sum;
return ;
}