QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#113675#5661. Multi-LaddersUFRJ#WA 0ms3524kbC++20951b2023-06-19 03:19:592023-06-19 03:20:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-19 03:20:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3524kb
  • [2023-06-19 03:19:59]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
using lint = int64_t;
const lint MOD = 1000000007;

lint mod(lint x){
    x %= MOD;
    x += MOD;
    x %= MOD;
    return x;
}

lint modpow(lint x, lint e){
    lint r = 1;
    for(; e; e >>= 1){
        if(e & 1) r = mod(r * x);
        x = mod(x * x);
    }
    return r;
}


void solve(){
    lint n, k, l;
    cin>>n>>k>>l;
    if(l < 2){
        cout<<"0\n";
        return;
    }
    if(l == 2){
        if(k % 2 == 0) cout<<"2\n";
        else cout<<"0\n";
        return;
    }

    lint cycle = modpow(-1,k) * modpow(l-1, k) + l - 1;
    cycle = mod(modpow(-1, k) * cycle);
    
    lint ladder = modpow( modpow((l-2) * (l-2) + l-1, n-1) , k );

    lint answer = mod(ladder * cycle);

    cout<<answer<<"\n";


}

int main(){
    cin.tie(0)->sync_with_stdio(false);
    int t; cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

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

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
536959608
52489881
53690844
994176158
218103365
148794338
991895211
693053429
883715672
80402569
0
0
122563013

result:

wrong answer 8th lines differ - expected: '243010659', found: '536959608'