QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#89304 | #5661. Multi-Ladders | katoli# | AC ✓ | 2ms | 3524kb | C++14 | 669b | 2023-03-19 17:06:28 | 2023-03-19 17:06:31 |
Judging History
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