Submission details
Task:Jubilee
Sender:TLE
Submission time:2025-11-08 15:54:21 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#20.43 sdetails
#30.42 sdetails
#40.01 sdetails
#50.01 sdetails
#60.01 sdetails
#7ACCEPTED0.01 sdetails
#8ACCEPTED0.01 sdetails
#90.42 sdetails
#10ACCEPTED0.01 sdetails
#110.01 sdetails
#120.42 sdetails
#130.01 sdetails
#140.01 sdetails

Code

#include <bits/stdc++.h>
#define fi first
#define se second
#define For(type, i, a, b) for (type i = (a); i <= (b); ++i)
#define endl '\n'
using namespace std;
 
typedef long long ll;
 
const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
 
const ll limit = 1e6 + 5;
 
ll a[limit], f[limit];
ll n, m;

const ll mod = 1e9 + 7;

ll pow(ll a, ll n)
{
    a %= mod;
    if(n == 1) return a % mod;
    int tmp = pow(a % mod, n / 2);
    return (n & 1) ? tmp % mod * tmp % mod * a % mod : tmp % mod * tmp % mod;
}

ll C(ll p, ll n){
    p++;
    n++;
    return f[n - 1] * pow(f[p - 1] * f[n - p], mod - 2) % mod;
}


void FastIn(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
 
void ReadIn(){
  cin >> n >> m;

  f[0] = 1; 
  for(ll i = 1; i <= 1e5 + 1; i++){
    f[i] = (f[i-1] % mod * i % mod) % mod; 
  }
  ll res = ((m % mod * (m - 1) % mod) % mod * pow(m - 1, n - 1) % mod) % mod + ((m % mod * (m- 1) % mod) % mod * pow((m - 2) * (m - 2), n - 1) % mod) % mod;
  cout << res;
}
int main(){
    FastIn();
    ReadIn();
}
// g++ -o output
// g++ F.cpp
// ./f.out

Test details

Test 1

Verdict: ACCEPTED

input
3 2

correct output
2

user output
2

Test 2

Verdict:

input
1 1

correct output
0

user output
(empty)

Test 3

Verdict:

input
1 1000000000

correct output
56

user output
(empty)

Test 4

Verdict:

input
2 1000000000

correct output
4088

user output
1000004095

Feedback: Incorrect character on line 1 col 1: expected "4088", got "1000004095"

Test 5

Verdict:

input
3 1000000000

correct output
298424

user output
371000

Feedback: Incorrect character on line 1 col 1: expected "298424", got "371000"

Test 6

Verdict:

input
1000000 1000000000

correct output
859388820

user output
416775251

Feedback: Incorrect character on line 1 col 1: expected "859388820", got "416775251"

Test 7

Verdict: ACCEPTED

input
2 1

correct output
0

user output
0

Test 8

Verdict: ACCEPTED

input
1000000 1

correct output
0

user output
0

Test 9

Verdict:

input
1 2

correct output
2

user output
(empty)

Test 10

Verdict: ACCEPTED

input
1000000 2

correct output
2

user output
2

Test 11

Verdict:

input
1000000 3

correct output
129870828

user output
705126183

Feedback: Incorrect character on line 1 col 1: expected "129870828", got "705126183"

Test 12

Verdict:

input
1 3

correct output
6

user output
(empty)

Test 13

Verdict:

input
21355 1239478

correct output
74219157

user output
110934677

Feedback: Incorrect character on line 1 col 1: expected "74219157", got "110934677"

Test 14

Verdict:

input
531578 913517291

correct output
105420893

user output
1339710149

Feedback: Incorrect character on line 1 col 2: expected "105420893", got "1339710149"