将折痕分为竖直和水平,分别考虑。对折n次,有2^n-1贡献,结合二次项定理将公式进行化简。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#define ll long long
using namespace std;
const int maxn=6e6+6;
const ll mod=998244353;
const ll MOD=998244353;
ll power(ll x,ll a)
{
ll ans=1;
while(a)
{
if(a&1)
{
ans=ans*x%mod;
}
x=x*x%mod;
a>>=1;
}
return ans;
}
int main()
{
std::ios::sync_with_stdio(false);cin.tie(0);
int T;cin>>T;
while(T--)
{
ll n;
cin>>n;
ll k = power(2,n);
ll inv = power(k,mod-2);
ll ans = 1 + power(2,n) + power(3,n) * inv * 2 % mod;
cout<<ans%mod<<endl;
}
return 0;
}
本文地址:https://blog.csdn.net/CreatureNoWords/article/details/107900195
如对本文有疑问, 点击进行留言回复!!
Codeforces Round #662 (Div. 2) D. Rarity and New Dress
CodeForces 1393C Pinkie Pie Eats Patty-cakes
Codeforces Round #662 (Div. 2) A - Rainbow Dash, Fluttershy and Chess Coloring
网友评论