QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#109295#5661. Multi-Ladderschenshi#AC ✓1ms1756kbC++799b2023-05-28 10:07:242023-05-28 10:07:28

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-28 10:07:28]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:1756kb
  • [2023-05-28 10:07:24]
  • 提交

answer

#include<cstdio>
using namespace std;
const int MOD=1e9+7;
inline int qp(int b,int f){int res=1;for(;f;f>>=1,b=b*1ll*b%MOD) if(f&1) res=res*1ll*b%MOD;return res;}
int L,n,K,c;
struct Matrix{
	int a[2][2];
	Matrix operator*(const Matrix&b){
		Matrix res;
		for(int i=0;i<2;++i) for(int j=0;j<2;++j)
			for(int k=res.a[i][j]=0;k<2;++k) res.a[i][j]=(res.a[i][j]+a[i][k]*1ll*b.a[k][j])%MOD;
		return res;
	}
}A,B;
int main(){
	for(scanf("%d",&L);L--;printf("%lld\n",(c*(c-1ll)%MOD*B.a[0][0]+c*(c-1ll)%MOD*(c-2)%MOD*B.a[1][0])%MOD
	*qp((c-1+(c-2ll)*(c-2))%MOD,K*(n-1ll)%(MOD-1))%MOD)){
		scanf("%d%d%d",&n,&K,&c);
		A.a[0][0]=0;A.a[0][1]=c-1;A.a[1][0]=1;A.a[1][1]=c-2;
		B.a[0][0]=1;B.a[0][1]=0;B.a[1][0]=0;B.a[1][1]=1;
		for(int i=K-2;i;i>>=1,A=A*A) if(i&1) B=B*A;
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 1500kb

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: 0
Accepted
time: 1ms
memory: 1756kb

input:

20
2 3 3
1 3 3
10 3 0
10 3 2
1 21 2
1 22 0
2000 15000 2000
12000 30000 200000
1000000000 3 3
2 1000000000 3
2 3 100000000
1000000000 1000000000 10
1000000000 3 100000000
2 1000000000 100000000
1 1000000000 10
1 1000000000 100000000
1 1000 100000000
1000000000 1000000000 0
1000000000 1000000000 1
100...

output:

162
6
0
0
0
0
349400141
243010659
52489881
53690844
176686901
218103365
558243892
991895211
693053429
883715672
80402569
0
0
311752813

result:

ok 20 lines