记录编号 |
601107 |
评测结果 |
AAAAAAAAAA |
题目名称 |
3108.[GXOI/GZOI2019]逼死强迫症 |
最终得分 |
100 |
用户昵称 |
李奇文 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.061 s |
提交时间 |
2025-06-02 16:28:13 |
内存使用 |
3.81 MiB |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int C=5,mod=1e9+7;
int t;
int n;
struct mat{
int a[C][C];
mat(){memset(a,0,sizeof(a));}
mat operator*(const mat&b)const{
mat c;
for(int i=0;i<C;i++){
for(int k=0;k<C;k++){
for(int j=0;j<C;j++){
c.a[i][j]=(c.a[i][j]+(long long )a[i][k]*b.a[k][j])%mod;
}
}
}
return c;
}
}a;
mat pow(mat x,int y){
mat res;
res.a[0][0]=res.a[1][1]=res.a[2][2]=res.a[3][3]=res.a[4][4]=1;
for(;y;y>>=1,x=x*x){
if(y&1) res=res*x;
}
return res;
};
int main(){
freopen("obsession.in","r",stdin);
freopen("obsession.out","w",stdout);
scanf("%d",&t);
a.a[0][1]=1,a.a[1][1]=1,a.a[1][0]=1;
a.a[2][3]=1,a.a[3][2]=1,a.a[3][3]=1;
a.a[4][1]=mod-1,a.a[3][1]=2,a.a[4][4]=1;
while(t--){
scanf("%d",&n);
if(n<3){
printf("0\n");
continue;
}
mat ans;
ans.a[0][2]=1,ans.a[0][3]=ans.a[0][4]=2;
printf("%d\n",(ans*pow(a,n-2)).a[0][1]);
}
return 0;
}