#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; #define LL long long #define mod 998244353 LL n,x; struct matrix{ LL s[4][4]; matrix(){memset(s,0,sizeof s);} matrix operator * (const matrix &n) const { matrix c; for (int i=1;i<=3;++i) for (int j=1;j<=3;++j) for (int k=1;k<=3;++k) c.s[i][j]=(c.s[i][j]+s[i][k]*n.s[k][j])%mod; return c; } }ans,k,l; matrix pow(matrix k,LL x){ if (x==1) return k; matrix u=pow(k,x>>1); if ((x&1)==1) return u*u*k; else return u*u; } int main(){ while (~scanf("%lld",&x)){ k.s[1][1]=1; k.s[1][2]=1; k.s[2][1]=1; k.s[2][2]=0; l.s[1][1]=1; l.s[2][1]=1; ans=pow(k,x*2+1)*l; printf("%lld\n",((ans.s[1][1]-1)%mod+mod%mod)); } return 0; }
|