제출 #960643

#제출 시각아이디문제언어결과실행 시간메모리
960643teo_thrash캥거루 (CEOI16_kangaroo)C++14
6 / 100
1 ms2396 KiB
// it is your desire to work hard #include<bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> pii; const int maxn=2e3+3; const int mod=1e9+7; int n; int dp[maxn][maxn]; int cs, cf; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n; cin>>cs>>cf; dp[1][1]=1; for(int i=2; i<=n; i++){ for(int j=1; j<=n; j++){ int rem=0; if(i>cs) rem++; if(i>cf) rem++; if(i==cs or i==cf){ dp[i][j] = (dp[i-1][j-1])%mod + (dp[i-1][j])%mod; }else{ dp[i][j] = (dp[i-1][j+1]*j)%mod + (dp[i-1][j-1]*(j-rem))%mod; } dp[i][j]%=mod; } } cout<<dp[n][1]<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...