Submission details
Task:Jubilee
Sender:freefoodfreepoints
Submission time:2025-11-08 16:12:12 +0200
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.01 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.01 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.01 sdetails
#11ACCEPTED0.01 sdetails
#12ACCEPTED0.00 sdetails
#130.00 sdetails
#140.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:44:14: warning: variable 'diff' set but not used [-Wunused-but-set-variable]
   44 |         auto diff = total * (m - 2);
      |              ^~~~

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define til(n) for(ll i = 0; i < n; i++)

constexpr ll mod = 1e9+7;


ll euclid(ll a, ll b, ll& x, ll& y){
    if (!b) return x=1,y=0,a;
    ll d = euclid(b,a%b,y,x);
    return y-=a/b * x, d;
}

struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator* (Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/ (Mod b) { return *this * invert(b); }
    Mod operator- (Mod b) { return Mod((x-b.x+mod) % mod); }
    Mod operator+ (Mod b) { return Mod((x+b.x) % mod); }
    Mod invert(Mod a) {
        ll x,y,g = euclid(a.x,mod,x,y);
        assert (g==1);
        return Mod((x+mod) % mod);
    }
};


int main() {
    cin.tie(0)->sync_with_stdio(false);
    cout.tie(0)->sync_with_stdio(false);
    ll n2, m2;
    cin >> n2 >> m2;
    Mod n(n2);
    Mod m(m2);
    Mod total = 1;
    // first two seats at the end of the table
    total = total * m;
    total = total * (m - 1);
    til(n2-1) {
        auto same = total;
        auto diff = total * (m - 2);
        total = (same * (m-1)) + (total * (m-2));
    }
    cout << total.x << '\n';
}

Test details

Test 1

Verdict: ACCEPTED

input
3 2

correct output
2

user output
2

Test 2

Verdict: ACCEPTED

input
1 1

correct output
0

user output
0

Test 3

Verdict: ACCEPTED

input
1 1000000000

correct output
56

user output
56

Test 4

Verdict:

input
2 1000000000

correct output
4088

user output
999999055

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

Test 5

Verdict:

input
3 1000000000

correct output
298424

user output
16184

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

Test 6

Verdict:

input
1000000 1000000000

correct output
859388820

user output
97175181

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

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: ACCEPTED

input
1 2

correct output
2

user output
2

Test 10

Verdict: ACCEPTED

input
1000000 2

correct output
2

user output
2

Test 11

Verdict: ACCEPTED

input
1000000 3

correct output
129870828

user output
129870828

Test 12

Verdict: ACCEPTED

input
1 3

correct output
6

user output
6

Test 13

Verdict:

input
21355 1239478

correct output
74219157

user output
237148970

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

Test 14

Verdict:

input
531578 913517291

correct output
105420893

user output
937922067

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