QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#123358#5661. Multi-LaddersGenshinImpactsFault#AC ✓1ms3524kbC++14734b2023-07-12 13:24:192023-07-12 13:24:22

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-12 13:24:22]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3524kb
  • [2023-07-12 13:24:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MOD 1000000007
int Power(int x, int y) {
    int ret = 1;
    while(y) {
        if(y & 1) ret = 1ll * ret * x % MOD;
        y >>= 1;
        x = 1ll * x * x % MOD;
    }
    return ret;
} 
void Do() {
    int n, k, la;
    cin >> n >> k >> la;
    if(la <= 1) {
        cout << 0 << endl;
        return;
    }
    LL A = Power(Power((1ll*la*la-3*la+3)%MOD,n-1),k);
    LL B = Power(la-1,k)+((k&1)?-1:1)*(la-1);
    LL Ans = ((A*B)%MOD+MOD)%MOD;
    cout << Ans << endl;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // init();
    int T;
    cin >> T;
    while(T --) {
        Do();
    }
}

详细

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

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

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