제출 #204017

#제출 시각아이디문제언어결과실행 시간메모리
204017mahmoudbadawy캥거루 (CEOI16_kangaroo)C++17
6 / 100
5 ms376 KiB
#include <bits/stdc++.h> using namespace std; const int N=2005,MOD=1e9+7; long long mem[N][N]; int n,a,b; int main() { cin >> n >> a >> b; mem[1][1]=1; for(int i=2;i<=n;i++) { for(int j=1;j<=n;j++) { if(i==a||i==b) { mem[i][j]=mem[i-1][j]+mem[i-1][j-1]; if(mem[i][j]>=MOD) mem[i][j]-=MOD; continue; } mem[i][j]=mem[i-1][j-1]*(j-(i>a)+(i>b)); // add a new component mem[i][j]%=MOD; mem[i][j]+=mem[i-1][j+1]*j; // combine two existing components; } } cout << mem[n][1] << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...