QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#638692#5661. Multi-Ladderswmw#WA 0ms3584kbC++201.1kb2024-10-13 16:38:232024-10-13 16:38:23

Judging History

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

  • [2024-10-13 16:38:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2024-10-13 16:38:23]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define all(v) v.begin(), v.end()
#define prs(v) sort(all(v)); v.erase(unique(all(v)), v.end())
using namespace std;

constexpr int mod = 1'000'000'007;

auto modpow(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

auto sum_of_ratio(int a, int n, int r) {
    return a * (modpow(r, n) - 1 + mod) % mod * modpow(r - 1, mod - 2) % mod;
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    int t;
    cin >> t;

    while (t--) {
        int n, k, l;
        cin >> n >> k >> l;

        int include = sum_of_ratio((k & 1) ? (l - 1) * (l - 1) % mod : (l - 1), k / 2, (l - 1) * (l - 1) % mod);
        int exclude = sum_of_ratio((k & 1) ? (l - 1) : (l - 1) * (l - 1) % mod, (k - 1) / 2, (l - 1) * (l - 1) % mod);
        int sum = l * (include - exclude) % mod;
        int res = sum * (modpow(modpow((l * l - 3 * l + 3) % mod, n - 1), k)) % mod;
        cout << res << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3560kb

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
-650599866
243010659
52489881
53690844
176686901
218103365
558243892
-8104796
693053429
-116284335
80402569
0
0
-688247194

result:

wrong answer 7th lines differ - expected: '349400141', found: '-650599866'