QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#142295#5661. Multi-Laddersammardab3an#WA 1ms3564kbC++171.3kb2023-08-18 21:58:422023-08-18 21:58:48

Judging History

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

  • [2023-08-18 21:58:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3564kb
  • [2023-08-18 21:58:42]
  • 提交

answer

#include <bits/stdc++.h>

#define int int64_t
#define endl '\n'

using namespace std;

const int MOD = 1e9 + 7;

int add(int a, int b){
    int ret = (a*1ll + b) %MOD;
    if(ret < 0 ) ret += MOD;
    return ret;
}

int mul(int a, int b){
    int ret = (a*1ll * b)%MOD;
    if(ret < 0) ret += MOD;
    return ret;
}

int pow_exp(int n, int p){
    if(!p) return 1;
    if(p&1) return mul(n, pow_exp(n, p-1));
    int ret = pow_exp(n, p/2);
    return mul(ret, ret);
}

int inv(int n){
    return pow_exp(n, MOD-2);
}

int calc(int st, int q, int n){

    int a0 = add(pow_exp(q, n-1), -1);
    int a1 = add(q, -1);
    int a = mul(a0, inv(a1));

    return mul(st, a);
}

int32_t main()
{

    int t; cin >> t; while(t--){

        int n, k, l;
        cin >> n >> k >> l;

        if(l < 2){
            cout << 0 << endl;
            continue;
        }

        int a0 = mul(l-2, l-2);
        int a1 = add(a0, l-1);
        int a = pow_exp(a1, ((n-1)*k) % (MOD-1));

        int b0 = calc(mul(l-1, l-1), mul(l-1, l-1), k/2);
        int b1 = calc(l-1, mul(l-1, l-1), (k+1)/2);
        int b = k%2==0 ? add(b0, -b1) : add(b1, -b0);
        b = mul(b, l);

        int ans = mul(a, b);

        cout << ans << endl;

    }
}

詳細信息

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3564kb

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
315389363
933942130
52489881
319026494
304930780
471968387
422872637
669266971
632561486
968402557
911527908
0
0
631424855

result:

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