QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#135413 | #5661. Multi-Ladders | Nicolas125841 | WA | 1ms | 3600kb | C++17 | 977b | 2023-08-05 14:57:10 | 2023-08-05 14:57:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const ll mod = 1000000007;
ll modpow(ll b, ll e) {
ll ans = 1;
for (; e; b = b * b % mod, e /= 2)
if (e & 1) ans = ans * b % mod;
return ans;
}
int main(){
cin.tie(NULL)->sync_with_stdio(false);
int t;
cin >> t;
while(t--){
ll n, k, l;
cin >> n >> k >> l;
if(l < 2){
cout << "0\n";
continue;
}
ll spurs = (n == 1 ? 1 : modpow((n - 1) * ((l - 1) + modpow(l - 2, 2)) % mod, k));
ll ring = l * modpow(l - 1, k - 1) % mod - l * modpow(l - 1, k - 2) % mod;
ring %= mod;
if(ring < 0)
ring += mod;
cout << ring * spurs % mod << "\n";
}
}
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: -100
Wrong Answer
time: 1ms
memory: 3584kb
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 709722365 344475622 999917063 186358669 176686901 770865447 536307325 873610512 67213250 423049 869536635 0 0 790591717
result:
wrong answer 7th lines differ - expected: '349400141', found: '709722365'