QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#279112 | #7774. 基础寄术练习题 | lzytag | 25 | 0ms | 3796kb | C++14 | 792b | 2023-12-08 11:11:35 | 2023-12-08 11:11:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
int n,m,k,mod,lst,now;
ll f[2][N],inv[N*N];
void solve1()
{
lst = 1;
f[now][0] = 1;
for(int i = 1;i <= m;i++)
{
swap(now,lst);
memset(f[now],0,sizeof(f[now]));
for(int j = 0;j <= n;j++)
{
if(!f[lst][j]) continue;
f[now][j] = (f[now][j] + f[lst][j])%mod;
if(j < n) f[now][j+1] = (f[now][j+1] + f[lst][j]*inv[i])%mod;
}
}
cout<<f[now][n]<<"\n";
}
void solve2()
{
cout<<"114514\n";
}
int main()
{
cin>>n>>m>>k>>mod;
inv[1] = 1;
for(int i = 2;i <= n*m;i++) inv[i] = mod - mod/i*inv[mod%i]%mod;
if(k == 1) solve1();
if(k == 2) solve2();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 3584kb
input:
9 16 1 327134593
output:
162102742
result:
ok single line: '162102742'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
11 18 1 834359503
output:
256188485
result:
ok single line: '256188485'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
18 18 1 614802701
output:
552168146
result:
ok single line: '552168146'
Test #4:
score: -10
Wrong Answer
time: 0ms
memory: 3652kb
input:
7 16 2 861918403
output:
114514
result:
wrong answer 1st lines differ - expected: '306693876', found: '114514'
Subtask #2:
score: 25
Accepted
Test #6:
score: 25
Accepted
time: 0ms
memory: 3696kb
input:
60 98 1 715015339
output:
690737273
result:
ok single line: '690737273'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
96 97 1 507892589
output:
481151247
result:
ok single line: '481151247'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
90 95 1 621080027
output:
255353202
result:
ok single line: '255353202'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
85 94 1 297115421
output:
122254364
result:
ok single line: '122254364'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
81 91 1 460412027
output:
148037986
result:
ok single line: '148037986'
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 3640kb
input:
29 29 2 545875273
output:
114514
result:
wrong answer 1st lines differ - expected: '171843225', found: '114514'
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 0ms
memory: 3700kb
input:
27 30 2 360712453
output:
114514
result:
wrong answer 1st lines differ - expected: '80987914', found: '114514'
Subtask #5:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 0ms
memory: 3568kb
input:
29 38 2 909155077
output:
114514
result:
wrong answer 1st lines differ - expected: '745973305', found: '114514'
Subtask #6:
score: 0
Wrong Answer
Test #26:
score: 0
Wrong Answer
time: 0ms
memory: 3552kb
input:
57 66 2 767174999
output:
114514
result:
wrong answer 1st lines differ - expected: '315351738', found: '114514'
Subtask #7:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 0ms
memory: 3796kb
input:
96 96 2 453296971
output:
114514
result:
wrong answer 1st lines differ - expected: '222864385', found: '114514'