UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214178#2693. NEQThySecret0208ms16788kbC++111.6kb2024-11-15 22:08:502024-11-15 23:28:47

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
// #define x first
// #define y second
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)

inline void debug() { cerr << '\n'; }
template<typename Type, typename... Other>
inline void debug(const Type& x, const Other&... y) { cerr << x << ' '; debug(y...); }
#define DEBUG(a...) cerr << "[" << #a << "] = ", debug(a);

typedef long long LL;
typedef pair<int, int> PII;

const int N = 2000010;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

template<typename Type>
inline void read(Type &res)
{
    res = 0;
    int ch = getchar(), flag = 0;
    while (!isdigit(ch)) flag |= ch == '-', ch = getchar();
    while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
    res = flag ? -res : res;
}
template<typename Type, typename... Other>
inline void read(Type &res, Other&... y) { read(res), read(y...); }

int n, m;
int fc[N], f[N];

inline int ksm(int base, int k)
{
    int res = 1;
    while (k)
    {
        if (k & 1) res = res * base % mod;
        base = base * base % mod, k >>= 1;
    }
    return res;
}

inline int A(int m, int n) { return fc[m] * ksm(fc[m - n], mod - 2) % mod; }

void solve()
{
    read(n, m);
    f[0] = 1, f[1] = m - n;
    for (int i = 2; i <= n; i ++)
        f[i] = (f[i - 1] * (m - n) % mod + (i - 1) * (f[i - 1] + f[i - 2]) % mod) % mod;
    cout << A(m, n) * f[n] % mod << '\n';
}

signed main()
{
    for (int i = fc[0] = 1; i < N; i ++) fc[i] = fc[i - 1] * i % mod;
    solve();
    // int T; read(T);
    // while (T --) solve();
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 13ms
memory: 16784kb

input:

10
10 10
10 10
2 10
3 10
9 10
1 10
8 10
7 10
1 10
10 10

output:

306442892

result:

wrong answer 2nd lines differ - expected: '306442892', found: ''

Test #2:

score: 0
Wrong Answer
time: 10ms
memory: 16784kb

input:

10
5 10
1 10
8 10
3 10
4 10
7 10
5 10
8 10
10 10
9 10

output:

0

result:

wrong answer 1st lines differ - expected: '547011360', found: '0'

Test #3:

score: 0
Wrong Answer
time: 18ms
memory: 16788kb

input:

10
10 10
3 10
1 10
2 10
9 10
10 10
2 10
4 10
3 10
3 10

output:

306442892

result:

wrong answer 2nd lines differ - expected: '379440', found: ''

Test #4:

score: 0
Wrong Answer
time: 9ms
memory: 16788kb

input:

10
10 10
1 10
6 10
8 10
1 10
7 10
2 10
8 10
5 10
2 10

output:

306442892

result:

wrong answer 2nd lines differ - expected: '90', found: ''

Test #5:

score: 0
Wrong Answer
time: 9ms
memory: 16788kb

input:

10
209948 325367
32718 415553
23204 942400
112174 378481
606851 967435
136404 1014128
219328 240497
...

output:

893886813

result:

wrong answer 1st lines differ - expected: '486730033', found: '893886813'

Test #6:

score: 0
Wrong Answer
time: 10ms
memory: 16788kb

input:

10
138556 734356
435301 1331052
987730 1772096
814036 824058
46984 404156
483366 1120849
343377 9489...

output:

520130487

result:

wrong answer 1st lines differ - expected: '810123408', found: '520130487'

Test #7:

score: 0
Wrong Answer
time: 9ms
memory: 16788kb

input:

10
3667 227437
960664 1136884
126289 1829473
242537 1330052
375909 872744
356898 531785
229031 14944...

output:

437549363

result:

wrong answer 1st lines differ - expected: '417049407', found: '437549363'

Test #8:

score: 0
Wrong Answer
time: 4ms
memory: 16784kb

input:

10
567322 1929060
1001468 1289434
163254 319786
698923 843859
740264 759489
203918 1063292
508483 79...

output:

211119906

result:

wrong answer 1st lines differ - expected: '314836082', found: '211119906'

Test #9:

score: 0
Wrong Answer
time: 14ms
memory: 16784kb

input:

10
1132589 1775386
207807 262123
63505 1358101
1428754 1798082
418855 455426
73850 272549
48576 1778...

output:

593090920

result:

wrong answer 1st lines differ - expected: '734925409', found: '593090920'

Test #10:

score: 0
Wrong Answer
time: 8ms
memory: 16788kb

input:

10
1695462 1939750
29235 1185790
194617 546134
337070 554401
768444 1892158
332841 882745
154636 920...

output:

985823868

result:

wrong answer 1st lines differ - expected: '201885598', found: '985823868'

Test #11:

score: 0
Wrong Answer
time: 14ms
memory: 16788kb

input:

10
674754 1159686
406921 960658
932058 1996799
48795 455853
554994 1113156
121831 1251202
1177109 15...

output:

306260956

result:

wrong answer 1st lines differ - expected: '989838431', found: '306260956'

Test #12:

score: 0
Wrong Answer
time: 4ms
memory: 16788kb

input:

10
701259 1332249
16908 633852
601124 1004557
581334 1216395
715566 1429189
862389 1656521
1345860 1...

output:

712576670

result:

wrong answer 1st lines differ - expected: '978526302', found: '712576670'

Test #13:

score: 0
Wrong Answer
time: 11ms
memory: 16784kb

input:

10
509226 1079784
65211 359751
304345 1114412
270468 1517516
177717 1461562
4559 1484183
291180 1856...

output:

977022827

result:

wrong answer 1st lines differ - expected: '377614455', found: '977022827'

Test #14:

score: 0
Wrong Answer
time: 13ms
memory: 16784kb

input:

10
844547 1065326
12765 348551
197870 493940
891829 1952960
408481 766220
42263 225437
1177449 15681...

output:

690415558

result:

wrong answer 1st lines differ - expected: '264953803', found: '690415558'

Test #15:

score: 0
Wrong Answer
time: 8ms
memory: 16788kb

input:

10
62489 1977001
1570544 1875539
190951 1046439
1006494 1596866
206518 527273
30700 804024
655225 14...

output:

410741265

result:

wrong answer 1st lines differ - expected: '137231299', found: '410741265'

Test #16:

score: 0
Wrong Answer
time: 12ms
memory: 16788kb

input:

10
192607 393179
201595 598364
94889 116297
68937 362063
375790 1173019
4169 213558
197175 1639344
8...

output:

105005502

result:

wrong answer 1st lines differ - expected: '675256418', found: '105005502'

Test #17:

score: 0
Wrong Answer
time: 18ms
memory: 16788kb

input:

10
798288 1987237
157453 1550357
705426 990370
613123 1321568
899033 956256
44168 172324
819515 1170...

output:

27111534

result:

wrong answer 1st lines differ - expected: '632430667', found: '27111534'

Test #18:

score: 0
Wrong Answer
time: 10ms
memory: 16788kb

input:

10
967864 1453914
481508 1761132
600063 853502
157152 1439130
76065 845828
663705 780511
192271 7895...

output:

79729304

result:

wrong answer 1st lines differ - expected: '127432855', found: '79729304'

Test #19:

score: 0
Wrong Answer
time: 10ms
memory: 16788kb

input:

10
933205 1384428
454383 955044
102873 1155697
143556 1235390
1498546 1673058
550403 1705906
44112 1...

output:

497254126

result:

wrong answer 1st lines differ - expected: '981751684', found: '497254126'

Test #20:

score: 0
Wrong Answer
time: 4ms
memory: 16784kb

input:

10
837543 861815
41145 74826
16836 20151
281906 835757
82984 232797
228888 347747
303856 369347
4196...

output:

965173457

result:

wrong answer 1st lines differ - expected: '425350707', found: '965173457'