QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#183911#5661. Multi-Ladderstriplem5ds#AC ✓1ms3424kbC++231.4kb2023-09-20 00:18:132023-09-20 00:18:13

Judging History

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

  • [2023-09-20 00:18:13]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3424kb
  • [2023-09-20 00:18:13]
  • 提交

answer

/// Msaa el 5ra
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i, a, b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll

using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;

const int N = 5e5 + 5, LG = 18, MOD = 1e9 + 7;
const long double PI = acos(-1);
const long double EPS = 1e-7;

ll fast(ll b, ll e) {
    ll res = 1;
    for (; e; e >>= 1, b = b * b % MOD)
        if (e & 1)
            res = res * b % MOD;
    return res;
}

void doWork() {

    int n, k, l;
    cin >> n >> k >> l;
    if (l <= 1) {
        cout << "0\n";
        return;
    }
    ll ans = fast(l - 1, k);
    if (k & 1) ans = (ans + MOD - l + 1) % MOD;
    else ans = (ans + MOD - 1 + l) % MOD;
    cout << ans * fast(((l - 2) * (l - 2) + (l - 1)) % MOD, (n - 1) * k % (MOD - 1)) % MOD << '\n';
}

int32_t main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE

    int t = 1;
    cin >> t;
    while (t--) {
        doWork();
    }
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3424kb

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3392kb

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