QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#520797#5661. Multi-Laddersouo#WA 0ms3740kbC++201.2kb2024-08-15 15:51:092024-08-15 15:51:10

Judging History

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

  • [2024-08-15 15:51:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3740kb
  • [2024-08-15 15:51:09]
  • 提交

answer

#include <bits/stdc++.h>

#ifdef LOCAL
using std::cerr;

#else

#endif

#define F first
#define S second
#define pb push_back
#define ALL(x) begin(x), end(x)

using namespace std;
using pii = pair<int, int>;
using ll = long long;
const ll P = 1e9 + 7;

ll fpow(ll a, ll ti) {
    if (ti < 1) return 1;
    int tmp = fpow(a, ti>>1);
    tmp *= tmp;
    tmp %= P;
    if (ti & 1) return tmp * a % P;
    return tmp;
}

ll n, k, c;

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int tc = 1;
    cin >> tc;
    while (tc--) {
        cin >> n >> k >> c;
        if (n <= 3) {
            ll a3 = c * (c - 1) * (c - 2);
            ll t = (c - 1) + (c - 2) * (c - 2);
            t %= P;
            t = fpow(t, n - 1);
            t = fpow(t, k);
            ll ans = a3 * t % P;
            cout << ans << '\n';
            continue;
        }
        ll a3 = c * (c - 1) * (c - 2);
        ll an = c * fpow(c-1, 3) % P * (fpow(c - 1, n - 3) - 1) * fpow(c - 2, P - 2) % P;
        an = ((an % P) + P) % P;
        ll t = (c - 1) + (c - 2) * (c - 2);
        
        t %= P;
        t = fpow(t, n - 1);
        t = fpow(t, k);
        ll ans = an * t % P;
        cout << ans << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

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

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
249291421
232895870
84300509
854198195
333700085
0
236671914
984076112
720
590547303
590547303
0
0
865596539

result:

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