标签:https tchar ast 第一个 www 理解 const clu ++i
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define getchar nc
using namespace std;
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline ll read()
{
register ll x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return x*f;
}
inline void write(register int x)
{
if(!x)putchar('0');if(x<0)x=-x,putchar('-');
static int sta[20];register int tot=0;
while(x)sta[tot++]=x%10,x/=10;
while(tot)putchar(sta[--tot]+48);
}
struct mat{
int a[2][2];
inline mat()
{
memset(a,0,sizeof(a));
}
inline mat operator*(const mat&b)const{
mat c;
for(register int i=0;i<2;++i)
for(register int j=0;j<2;++j)
for(register int k=0;k<2;++k)
c.a[i][j]=(c.a[i][j]+1ll*a[i][k]*b.a[k][j])%mod;
return c;
}
}s,o,ans;
inline mat fastpow(register mat a,register ll b)
{
mat res;
res.a[0][0]=res.a[1][1]=1;
while(b)
{
if(b&1)
res=res*a;
a=a*a;
b>>=1;
}
return res;
}
int T;
ll n;
int main()
{
T=read();
s.a[0][0]=s.a[0][1]=s.a[1][0]=1;
o.a[0][0]=1;
while(T--)
{
n=read();
ans=o*fastpow(s,n-1);
write((1ll*ans.a[0][0]+ans.a[0][1]*2ll)%mod),puts("");
}
return 0;
}
标签:https tchar ast 第一个 www 理解 const clu ++i
原文地址:https://www.cnblogs.com/yzhang-rp-inf/p/10890998.html