# LOJ #6485 LJJ 学二项式定理

QwQ

LOJ #6485

### 代码

#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define p 998244353
#define rt register int
#define ll long long
using namespace std;
ll x=0;char zf=1;char ch=getchar();
while(ch!='-'&&!isdigit(ch))ch=getchar();
if(ch=='-')zf=-1,ch=getchar();
while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans,a[4],w[4];
int ksm(int x,int y){
int ans=1;
for(rt i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)
ans=1ll*ans*x%p;
return ans;
}
int main(){
w[0]=1;w[1]=ksm(3,(p-1)/4);w[2]=1ll*w[1]*w[1]%p;w[3]=1ll*w[1]*w[2]%p;
int sum=0;
for(rt j=0;j<4;j++){
const int v=ksm(1ll*s*w[j]%p+1,n);
for(rt i=0;i<4;i++){
(sum+=1ll*a[i]*v%p*w[4-i*j&3]%p)%=p;
}
}
writeln(1ll*sum*ksm(4,p-2)%p);
}
return 0;
}

posted @ 2019-01-14 14:29  Kananix  阅读(275)  评论(0编辑  收藏