QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#89304#5661. Multi-Ladderskatoli#AC ✓2ms3524kbC++14669b2023-03-19 17:06:282023-03-19 17:06:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-19 17:06:31]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3524kb
  • [2023-03-19 17:06:28]
  • 提交

answer

#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll=long long;

const int MOD=1e9+7;
ll qpow(ll x,ll y){
	x+=MOD;
	x%=MOD;
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res*=x,res%=MOD;
		x*=x;
		x%=MOD;
	}
	return res;
}


int cal(){
	ll n,k,l;cin>>n>>k>>l;
	ll ans=qpow(l*l-3*l+3,k*(n-1));
	if(l<2)return 0;
	ans*=(qpow(l-1,k)+qpow(-1,k)*(l-1)%MOD)%MOD;
	ans%=MOD;
	return ans;
}
signed main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int T;cin>>T;
	while(T--){
		cout<<cal()<<endl;
	}
	return 0;
}
// init?
// var->0?
// infinite dfs?
// out of bound?
// max_element / min_element?

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3524kb

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3308kb

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