牛客训练五:炫酷数学(思维)

题目链接:传送门

思路:对于2^n个数,总共有4^n种两两组合,

考虑每个数的每一位,总共有(0,1)(0,0)(1,0)三种情况,所以只要3^n种就行了。

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
const LL MOD = 998244353;
int main(void)
{
    LL n,i,ans;
    while(~scanf("%d",&n)){
        ans=1;
        for(i=1;i<=n;i++) ans=ans*3%MOD;
        printf("%lld\n",ans);
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/2018zxy/p/10351226.html