Codeforces 367E Sereja and Intervals (dp + sqrt)
来源:互联网 发布:南昌淘宝照片拍摄的 编辑:程序博客网 时间:2024/06/05 16:18
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <queue> #include <set> #include <ctime> #include <cstdlib> using namespace std; #define inf 0x3f3f3f3f#define N 100020#define LL long long#define mod 1000000007#define ls (i << 1)#define rs (ls | 1)#define md (ll + rr >> 1)#define lson ll, md, ls#define rson md + 1, rr, rs#define B 350int n, m, X;int dp[40000020];void add(int &x, int y) {x += y;if(x >= mod) x -= mod;}int &f(int i, int x, int y) {int t = i * (n + 2) * (n + 2) + x * (n + 2) + y;return dp[t];}int main() {scanf("%d%d%d", &n, &m, &X);if(n > m) {puts("0");return 0;}dp[0] = 1;for(int i = 1; i <= m; ++i) {for(int x = 0; x <= i && x <= n; ++x) {for(int y = 0; y <= x; ++y) {if(i == X) {if(y > 0) add(f(i, x, y), f(i - 1, x - 1, y - 1));else f(i, x, y) = 0;if(x > 0) add(f(i, x, y), f(i - 1, x - 1, y));}else {add(f(i, x, y), f(i - 1, x, y + 1));if(y > 0) add(f(i, x, y), f(i - 1, x - 1, y - 1));add(f(i, x, y), f(i - 1, x, y));if(x > 0) add(f(i, x, y), f(i - 1, x - 1, y));}}}}int ans = f(m, n, 0);for(int i = 1; i <= n; ++i) ans = 1LL * ans * i % mod;printf("%d\n", ans);return 0;}
0 0
- Codeforces 367E Sereja and Intervals (dp + sqrt)
- Codeforces 367E Sereja and Intervals DP
- Codeforces 315E Sereja and Subsequences【思维+Dp】
- CodeForces 425E Sereja and Sets
- Codeforces 314E Sereja and Squares
- codefroces 425E Sereja and Sets (dp)
- Codeforces 426E Sereja and Two Sequences【思维+Dp+二分】好题!
- Codeforces 401B Sereja and Contests(DP)
- CodeForces 315E - Sereja and Subsequences 阅读理解+树状数组
- codeforces 381E Sereja and Brackets(线段树)
- Codeforces 381E Sereja and Brackets(线段树)
- Codeforces Round #223 (Div. 2) E Sereja and Brackets
- Codeforces 367A Sereja and Algorithm
- CodeForces 367A-Sereja and Algorithm【规律】
- Codeforces 367A Sereja and Algorithm 【规律】
- 【codeforces 367A Sereja and Algorithm】+ 预处理
- CodeForces 367A Sereja and Algorithm
- Codeforces Sereja and Mirroring
- 小米note开启调试模式
- 欢迎使用CSDN-markdown编辑器
- 给linux移植Ethercat笔记
- RxJavaRxAndroid入门资料 基本方法
- 浅析onsubmit校验表单时利用ajax的return false无效问题
- Codeforces 367E Sereja and Intervals (dp + sqrt)
- 关于前端的一点点感触
- oracle操作
- Rails 3 修改url中默认的的/:id
- linux安装cnn库
- 使用 python 创建最简单的 https 服务器
- PHP生成器、闭包
- 各种排序算法的分析及java实现
- Python 字符串操作