QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#182984 | #5661. Multi-Ladders | bonginn | AC ✓ | 0ms | 3620kb | C++14 | 1.1kb | 2023-09-18 20:12:38 | 2023-09-18 20:12:38 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define IOS cin.tie(0);ios_base::sync_with_stdio(false);
#define INF 1e15+9
using namespace std;
const int maxn = 2e5+5;
typedef pair<int,int> P;
const int MOD = 1e9 + 7;
int pow(int now,int k){
if(k <= 0) return 1;
if(k == 1) return now % MOD;
if(k % 2){
int tmp = pow(now,k-1);
return (now * tmp) % MOD;
}
else{
int tmp = pow(now,k / 2);
return (tmp * tmp) % MOD;
}
}
void solve(){
int n,k,l;
cin >> n >> k >> l;
int fl;
if(k % 2) fl = -1;
else fl = 1;
int in = (pow(l - 1,k) + fl * (l - 1)) % MOD;
//int in = ((l * ((pow(l - 1,k - 3) * 1 * (l - 1)) % MOD)) % MOD) + ((((l * pow(l - 1,k - 2)) % MOD) * (l - 1)) % MOD) % MOD;
int tmp = (l * l - 3 * l + 3) % MOD;
int num = (n - 1) * k;
cout << (in * pow(tmp,num)) % MOD;
cout << '\n';
//cout << in;
}
signed main(){IOS
int T;
cin >> T;
while(T--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
1 2 3 3
output:
162
result:
ok single line: '162'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
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