QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#375643 | #5532. Kangaroo | sichengzhou | 0 | 0ms | 3908kb | C++14 | 2.6kb | 2024-04-03 14:29:41 | 2024-04-03 14:29:41 |
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2020,mod=1e9+7;
int n,cs,cf;
LL f[N][N];
int main()
{
scanf("%d%d%d",&n,&cs,&cf);
f[0][0]=1;
for(int i=0;i<n;i++)
{
for(int j=0;j<=i;j++)
{
if(i+1==cs)
{
if(cf<=i)
{
if(j>=2)
{
f[i+1][j]+=f[i][j]*(j-1)%mod;
f[i+1][j]%=mod;
}else if(j==1)
{
f[i+1][j]+=f[i][j]*j%mod;
f[i+1][j]%=mod;
}
}else{
if(j>=1)
{
f[i+1][j]+=f[i][j]*j%mod;
f[i+1][j]%=mod;
}
}
}else if(i+1==cf)
{
if(cs<=i)
{
if(j>=2)
{
f[i+1][j]+=f[i][j]*(j-1)%mod;
f[i+1][j]%=mod;
}else if(j==1)
{
f[i+1][j]+=f[i][j]*j%mod;
f[i+1][j]%=mod;
}
}else{
if(j>=1)
{
f[i+1][j]+=f[i][j]*j%mod;
f[i+1][j]%=mod;
}
}
}else{
if(i<cs&&i<cf)
{
if(j>=2)
{
f[i+1][j-1]+=j*(j-1)%mod*f[i][j]%mod;
f[i+1][j-1]%=mod;
}
}else if(cs<=i&&cf<=i)
{
if(j>=2)
{
f[i+1][j-1]+=((j-1)*(j-1)-(j-2)-1)%mod*f[i][j]%mod;
f[i+1][j-1]%=mod;
}
}else if(cs<=i)
{
if(j>=2)
{
f[i+1][j-1]+=(j*(j-1)-(j-1))%mod*f[i][j]%mod;
f[i+1][j-1]%=mod;
}
}else{
if(j>=2)
{
f[i+1][j-1]+=(j*(j-1)-(j-1))%mod*f[i][j]%mod;
f[i+1][j-1]%=mod;
}
}
}
f[i+1][j+1]+=f[i][j];
f[i+1][j+1]%=mod;
}
}
printf("%lld\n",f[n][1]);
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3908kb
input:
7 3 6
output:
0
result:
wrong answer 1st numbers differ - expected: '14', found: '0'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%