Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <algorithm>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <cstring>
- using namespace std;
- typedef long long ll;
- int films, days, passed;
- ll dp[200][200];
- ll rec(int days_left, int films_left) {
- if(days_left == 0 and films_left == 0) {
- return 1;
- }
- if(days_left == 0) {
- return 0;
- }
- if(dp[days_left][films_left] != -1) {
- return dp[days_left][films_left];
- }
- ll ret = 0;
- ll MOD = 1e9 + 7;
- ret += (rec(days_left - 1, films_left - 1) % MOD) * (ll) (films - films_left + 1);
- ret %= MOD;
- ret += rec(days_left - 1, films_left) * max(0LL, (ll) (films_left - passed));
- ret %= MOD;
- return dp[days_left][films_left] = ret % MOD;
- }
- int main(){
- ios_base::sync_with_stdio(false);
- cin >> films >> days >> passed;
- memset(dp, -1, sizeof dp);
- cout << rec(days, films) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement