Paperfolding

https://vjudge.net/contest/387654#problem/I

算数学期望

对折和切刀都会使数量翻倍

横着切刀和上下对着效果相同,竖着切刀和左右对折效果相同

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))

#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair pii;
typedef char ch;
typedef double db;

const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10;
const int N=1e6+10;
const int mod=1e9+7;



ll MOD = 998244353;
ll P(ll k , ll n)
{
    ll base = 1;
	k %= MOD;
    while(n)
	{
        if(n & 1)
		{
            base = base * k % MOD;
        }
        k = k * k % MOD;
		n >>= 1;
    }
    return base;
}
int main()
{
	int T = 0;
	ll n = 0 , ans = 0;
    cin >> T;
    while(T--)
	{
        cin >> n;
		
		ans = 2 * P(3 , n) % MOD;
		ll temp = P(2 , n);
        ans *= P(temp , MOD-2);
		ans %= MOD;
        ans += 1 + temp;
		ans %= MOD;
        cout << ans < 
   

  

你可能感兴趣的:(Paperfolding)