#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int N=2005;
int add(int x, int y){ x+=y;return x>=mod?x-mod:x;}
void ADD(int &x, int y){ x=add(x,y);}
int sub(int x, int y){ x-=y;return x<0?x+mod:x;}
void SUB(int &x, int y){ x=sub(x,y);}
int dp[2][N][N],sum[2][N][N];
int Get(int i, int l, int r, int t)
{
return sub(sum[t][i][r],sum[t][i][l-1]);
}
int main()
{
int n,cs,cf;
scanf("%i %i %i",&n,&cs,&cf);
dp[0][1][1]=dp[1][1][1]=1;
for(int l=2;l<=n;l++)
{
for(int t=0;t<2;t++)
for(int i=1;i<=l;i++)
for(int j=1;j<=l;j++)
sum[t][i][j]=add(sum[t][i][j-1],dp[t][i][j]),dp[t][i][j]=0;
for(int i=1;i<=l;i++)
for(int j=1;j<=l;j++)
{
dp[0][i][j]=Get(i-(i>j),1,j-1,1);
dp[1][i][j]=Get(i-(i>j),j,l,0);
}
}
int ans=add(dp[0][cs][cf],dp[1][cs][cf]);
printf("%i\n",ans);
return 0;
}
Compilation message
kangaroo.cpp: In function 'int main()':
kangaroo.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i %i %i",&n,&cs,&cf);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |