ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#213831 | #2406. Thief Masters | huangyuhe | 0 | 3ms | 1200kb | C++11 | 1.0kb | 2024-11-13 21:07:59 | 2024-11-13 23:07:41 |
answer
#include <bits/stdc++.h>
#define C__ const
#define int long long
using namespace std;
C__ int N_ = 1e6 + 10;
int n, p;
namespace Task1 {
bool vis[N_];
int dfs(int pos, int last) {
if (pos > n * 2) return 1;
int res = 0;
if (pos & 1) {
for (int i = 1; i <= n * 2; i++)
if (!vis[i]) {
vis[i] = true;
res += dfs(pos + 1, last);
vis[i] = false;
break;
}
} else {
for (int i = last + 1; i <= n + pos / 2; i++)
if (!vis[i]) {
vis[i] = true;
res += dfs(pos + 1, i);
vis[i] = false;
}
}
return res;
}
}
inline int fpow(int a, int b, int MOD) { int c = 1; for (; b; (a *= a) %= MOD, b >>= 1) if (b & 1) (c *= a) %= MOD; return c; }
inline int inv(int a, int MOD) { return fpow(a, MOD - 2, MOD); }
signed main() {
cin >> n >> p;
int facn = 1, fac2n = 1;
for (int i = 1; i <= n; i++) (facn *= i) %= p;
fac2n = facn;
for (int i = n + 1; i <= n + n; i++) (fac2n *= i) %= p;
cout << inv(n + 1, p) * fac2n % p * inv(facn * facn % p, p) % p << "\n";
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1200kb
input:
1000 1000 100 804544523 340648618 718292412 235345736 704741136 942776831 741228920 463473302 677289...
output:
0
result:
wrong answer 1st lines differ - expected: '998893495', found: '0'
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 1200kb
input:
5 4 2 1 2 5 6 0 17 16 0 16 17 0 1 2 10 2 1 1 2 3 2
output:
0
result:
wrong answer 1st lines differ - expected: '2', found: '0'
Test #3:
score: 0
Wrong Answer
time: 0ms
memory: 1200kb
input:
100 100 10 2 100001 200001 300001 400001 500001 600001 700001 800001 900001 1000001 1100001 1200001 ...
output:
0
result:
wrong answer 1st lines differ - expected: '908999', found: '0'
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
1000 1000 20 1 100001 200001 300001 400001 500001 600001 700001 800001 900001 1000001 1100001 120000...
output:
0
result:
wrong answer 1st lines differ - expected: '1901899', found: '0'
Test #5:
score: 0
Wrong Answer
time: 0ms
memory: 1200kb
input:
500 500 50 79289095 232165705 955620938 481434262 465576217 112035388 50089892 459799006 181906335 3...
output:
0
result:
wrong answer 1st lines differ - expected: '995944328', found: '0'
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 1196kb
input:
500 1000 80 499163842 331022295 940054497 684192083 248823911 842132608 629298697 398526298 98438040...
output:
0
result:
wrong answer 1st lines differ - expected: '998299092', found: '0'
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
1000 1000 80 102 134 429 251 299 109 264 669 727 296 112 550 270 270 544 660 131 546 968 219 113 678...
output:
0
result:
wrong answer 1st lines differ - expected: '998', found: '0'
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 1196kb
input:
500 500 100 65532583 920409544 753795976 989349545 818384831 778207112 425141881 853270293 542112588...
output:
0
result:
wrong answer 1st lines differ - expected: '999172505', found: '0'
Test #9:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
500 1000 100 456896744 779471086 578349238 52507342 192194992 156396237 475084995 775765435 96617474...
output:
0
result:
wrong answer 1st lines differ - expected: '998801667', found: '0'
Test #10:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
1000 1000 100 629053044 957239666 456746076 940194386 201529807 592062148 244394389 825620014 223976...
output:
0
result:
wrong answer 1st lines differ - expected: '998862873', found: '0'