luogu CF584B Kolya and Tanya |數學

题目大意:给出n个等边三角形,每个顶点都可以是1~3中的一个数,一个等边三角形三个顶点的总和不能是6。在n个三角形中只要有一个等边三角形满足条件,当前情况就是合法的,问有多少种合法的情况。


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
#define int long long
inline int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1)res=res*x%mod;
		x=x*x%mod; y>>=1;
	}
	return res;
}
signed main(){
	int n; cin>>n;
	printf("%lld\n",(ksm(27,n)-ksm(7,n)+mod)%mod);
}

猜你喜欢

转载自www.cnblogs.com/naruto-mzx/p/12689478.html
今日推荐