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

 

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

 

数学推导题

 

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 #define minv 1e-6
 5 #define inf 1e9
 6 #define pi 3.1415926536
 7 #define nl 2.7182818284
 8 const ll mod=998244353;
 9 const int maxn=1e5+10;
10 
11 ll mul(ll a,ll b)
12 {
13     ll y=1;
14     while (b)
15     {
16         if (b & 1)
17             y=y*a%mod;
18         b>>=1;
19         a=a*a%mod;
20     }
21     return y;
22 }
23 
24 int main()
25 {
26     int n,m,g,b,preb,len,i;
27     ll sum=1,v;
28     scanf("%d%d%d",&n,&m,&g);
29     preb=0;
30     for (i=1;i<=m;i++)
31     {
32         scanf("%d",&b);
33         len=b-preb;
34         v=mul(g,len);
35         sum=(sum*v%mod*(v+1)%mod*499122177)%mod;
36         preb=b;
37     }
38     v=mul(g,n-2*b);
39     sum=sum*v%mod;
40     cout<<sum;
41     return 0;
42 }

 

posted @ 2018-10-23 18:54  congmingyige  阅读(141)  评论(0编辑  收藏  举报