QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#89291 | #5661. Multi-Ladders | katoli# | WA | 2ms | 3556kb | C++14 | 742b | 2023-03-19 16:08:54 | 2023-03-19 16:08:58 |
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){
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(k==3){
ans*=l;ans%=MOD;
ans*=(l-1);ans%=MOD;
ans*=(l-2);ans%=MOD;
}else{
ans*=(l*qpow(l-1,k-3)%MOD*(l-2)%MOD+l*qpow(l-1,k-2)%MOD*(l-2)%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();
}
return 0;
}
// init?
// var->0?
// infinite dfs?
// out of bound?
// max_element / min_element?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3556kb
input:
1 2 3 3
output:
162
result:
ok single line: '162'
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3364kb
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:
16260000888263007844830037524898817795380075432418582247622219930224791815028719635702848825271449462797950059402164
result:
wrong answer 1st lines differ - expected: '162', found: '162600008882630078448300375248...2848825271449462797950059402164'