zoukankan      html  css  js  c++  java
  • Paperfolding

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

    算数学期望

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

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

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<bitset>
    #include<cassert>
    #include<cctype>
    #include<cmath>
    #include<cstdlib>
    #include<ctime>
    #include<deque>
    #include<iomanip>
    #include<list>
    #include<map>
    #include<queue>
    #include<set>
    #include<stack>
    #include<vector>
    #include <vector>
    #include <iterator>
    #include <utility>
    #include <sstream>
    #include <limits>
    #include <numeric>
    #include <functional>
    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<int,int> 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 <<endl;
        }
        return 0;
    }
    

      

  • 相关阅读:
    练习:给Keras ResNet50源码加上正则化参数, 修改激活函数为Elu
    凸集,凸函数,凸优化问题。
    Keras用动态数据生成器(DataGenerator)和fitgenerator动态训练模型
    Lagrangian 对偶 和 Slater 条件
    凸集分离定理
    Python 中的 sorted 和 sort的区别
    工作反思
    jemalloc
    libcoap
    dropbear
  • 原文地址:https://www.cnblogs.com/SutsuharaYuki/p/13460321.html
Copyright © 2011-2022 走看看