QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103479#5661. Multi-Ladderscardinal_city#AC ✓2ms3396kbC++171.2kb2023-05-06 03:56:402023-05-06 03:56:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-06 03:56:41]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3396kb
  • [2023-05-06 03:56:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size();
#define rep(i,j,k) for (int i = j; i < (k); i++)
#define in(mp, v) (mp.find(v) != mp.end())
#define smx(a, b) a = max(a, b)
#define smn(a, b) a = min(a, b)
#define pb push_back
#define endl '\n'

const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;

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(0)->sync_with_stdio(0);

    int t; cin >> t;
    while (t--) {
        ll n, k, l; cin >> n >> k >> l;
        if (l < 2 || (k % 2 == 1 && l < 3)) {
            cout << 0 << "\n";
            continue;
        }

        ll p1 = modpow(l - 1, k);
        p1 += (k % 2 == 1 ? -1 : 1) * (l - 1);
        while (p1 < 0) {
            p1 += MOD;
        }
        p1 %= MOD;

        ll p = (l * l - 3 * l + 3 + 5 * MOD) % MOD;
        ll p2 = modpow(p, (n - 1) * k);

        cout << p1 * p2 % MOD << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3316kb

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