QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#219356#5661. Multi-LaddersJenniferLing#WA 1ms3440kbC++17939b2023-10-19 13:15:032023-10-19 13:15:03

Judging History

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

  • [2023-10-19 13:15:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3440kb
  • [2023-10-19 13:15:03]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int M = 1e9 + 7;

int mypw(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) (res *= x) %= M;
    (x *= x) %= M;
    y >>= 1;
  }
  return res;
}

int mul(int x, int y) {
  return (x * y) % M;
}

void solve() {
  int n, k, l; cin >> n >> k >> l;
  if (l == 0 || l == 1) { 
    cout << "0\n";
    return;
  }
  if (l == 2) {
    if (n & 1) cout << "0\n";
    else cout << mypw((mypw(l - 1, 2) - 1 + M) % M, (n - 1) * k) << "\n";
    return;
  }
  if (k & 1) cout << mul(mypw((mypw(l - 1, 2) - 1 + M) % M, (n - 1) * k), (mypw(l - 1, k) - (l - 1) * (l - 2) % M + M) % M) << "\n";
  else cout << mul(mypw((mypw(l - 1, 2) - 1 + M) % M, (n - 1) * k), (mypw(l - 1, k) + (l - 1) * (l - 2) % M) % M) << "\n";
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  cin >> T;
  while (T--) solve();
}

详细

Test #1:

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

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
846531572
830900884
52489881
53690844
165329838
787311498
909437089
821884898
693053492
413715675
610402579
0
0
215179816

result:

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