传送门
思路:Cn0+Cn1+Cn2+…=2 ^ n=(1+1)^n
Cn0-Cn1+Cn2+…=(1-1)^n
将上面两式相加
得到Cn0+Cn2+…=2^n-1
且
从而得出答案
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 998244353;
ll qpow(ll a,ll b)
{
ll ans = a%mod;
ll sum = 1;
while(b)
{
if(b&1)
sum = sum*ans%mod;
ans = ans*ans%mod;;
b /=2;
}
return sum%mod;
}
int main()
{
ll n;
scanf("%lld",&n);
ll m = n/4;
if(m%2)
{
ll ans = qpow(4,m*2-1) - qpow(2, m*2-1);
ans = (ans + mod)%mod;
printf("%lld\n",(ans+mod)%mod);
}
else
{
printf("%lld\n",(qpow(2, m*2-1)%mod + qpow(4, m*2-1)%mod)%mod);
}
}