QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#32483#874. Long Grid CoveringFroggyguaWA 3ms3544kbC++1001b2022-05-20 16:52:392022-05-20 16:52:41

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-20 16:52:41]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3544kb
  • [2022-05-20 16:52:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll n;
struct Matrix{
	int g[7][7];
	Matrix(){memset(g,0,sizeof(g));}
	friend Matrix operator * (const Matrix &a,const Matrix &b){
		Matrix c;
		for(int i=1;i<=6;++i){
			for(int j=1;j<=6;++j){
				for(int k=1;k<=6;++k){
					c.g[i][j]=(c.g[i][j]+1LL*a.g[i][k]*b.g[k][j])%mod;
				}
			}
		}
		return c;
	}
}e;
// [ dp[n] dp[n-1] dp[n-2] s[n-1] s[n-2] s[n-3] ]
Matrix mpow(Matrix a,ll b){
	Matrix ans=e;
	while(b){
		if(b&1)ans=ans*a;
		a=a*a;
		b>>=1;
	}
	return ans;
}
void Solve(){
	cin>>n;
	Matrix s;
	s.g[1][2]=s.g[2][3]=1;
	s.g[4][5]=s.g[5][6]=1;
	s.g[1][1]=1;
	s.g[3][1]=1;
	s.g[4][1]=2;
	s.g[5][1]=4;
	s.g[1][4]=1;
	s.g[6][4]=1;
	Matrix pre;
	pre.g[1][1]=1;
	Matrix ans=pre*mpow(s,n);
	cout<<ans.g[1][1]<<'\n';
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	for(int i=1;i<=6;++i)e.g[i][i]=1;
	int T;
	cin>>T;
	while(T--)Solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3544kb

input:

4
1
2
3
10

output:

1
3
10
6856

result:

wrong answer 4th numbers differ - expected: '8266', found: '6856'