Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of integers [l, r] (1 ≤ l ≤ r ≤ m). Interval [l1, r1] belongs to interval [l2, r2] if the following condition is met: l2 ≤ l1 ≤ r1 ≤ r2.

Sereja wants to write out a sequence of n intervals [l1, r1], [l2, r2], ..., [ln, rn] on a piece of paper. At that, no interval in the sequence can belong to some other interval of the sequence. Also, Sereja loves number x very much and he wants some (at least one) interval in the sequence to have li = x. Sereja wonders, how many distinct ways to write such intervals are there?

Help Sereja and find the required number of ways modulo 1000000007 (109 + 7).

Two ways are considered distinct if there is such j (1 ≤ j ≤ n), that the j-th intervals in two corresponding sequences are not equal.

Input

The first line contains integers n, m, x (1 ≤ n·m ≤ 100000, 1 ≤ x ≤ m) — the number of segments in the sequence, the constraints on the numbers in segments and Sereja's favourite number.

Output

In a single line print the answer modulo 1000000007 (109 + 7).

Examples

Input
1 1 1
Output
1
Input
3 5 1
Output
240
Input
2 3 3
Output
6

Note

In third example next sequences will be correct: {[1, 1], [3, 3]}, {[1, 2], [3, 3]}, {[2, 2], [3, 3]}, {[3, 3], [1, 1]}, {[3, 3], [2, 2]}, {[3, 3], [1, 2]}.

题意:给定长度为M的数轴,让你选择N个带编号的线段,使得没有线段有包含关系。 给定X,让你至少选择了一个左端点为X的线段。

思路:N<=M;  所以N<sqrt(N*M)<=330; 没有包含关系,那么线段A的左端点大于B的左端点,那么A的右端点也一定大于B的右端点。所以我们可以自己去匹配。只保存当点左端点和右端点个数即可。

用dp[i][j][x]表示前x个点选择了i个左端点,j个右端点,不难得到方程。由于x可能有点大,我们用滚动数组。

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=;
const int Mod=1e9+;
int dp[maxn][maxn][];
int main()
{
int N,M,X;
scanf("%d%d%d",&N,&M,&X);
if(N>M) return puts(""),;
dp[][][]=;
rep(k,,M){//位置
rep(i,,min(N,M)){ //左括号
rep(j,,i){ //右括号
int p=k&;
if(k==X){
dp[i][j][p]=;
if(i>j) (dp[i][j][p]+=dp[i-][j][p^])%=Mod; //左
if(i&&j) (dp[i][j][p]+=dp[i-][j-][p^])%=Mod;//左+右
}
else {
dp[i][j][p]=dp[i][j][p^]; //不放
if(i>j) (dp[i][j][p]+=dp[i-][j][p^])%=Mod; //左
if(i&&j) (dp[i][j][p]+=dp[i-][j-][p^])%=Mod;//左+右
if(j) (dp[i][j][p]+=dp[i][j-][p^])%=Mod;//右
}
}
}
}
rep(i,,N) dp[N][N][M&]=1LL*dp[N][N][M&]*i%Mod;
printf("%d\n",dp[N][N][M&]);
return ;
}

最新文章

  1. 警告: [unchecked] 对作为原始类型IScheme的成员的write(TProt ocol,T)的调用未经过检查
  2. 导航栏和里面的View设置的是同一颜色值,实际运行又不一样.
  3. DIV+CSS命名规范-转载2
  4. JDBC 学习笔记(二)—— 大数据+存储过程+批处理+事务管理
  5. squid3.0 隐藏 hearder 设置
  6. How to convert an IPv4 address into a integer in C#?
  7. Top 15 Tools To Make Animated GIFs From Images &amp; Video
  8. vc++ ODBC
  9. android中利用view画出一条竖线
  10. Hibernate的介绍
  11. Atitit.dwr3 不能显示错误具体信息的解决方式,控件显示错误具体信息的解决方式 java .net php
  12. Nagios监控生产环境redis群集服务战
  13. Tsung记录
  14. tomcat的几种配置方式(常用)
  15. 一般css样式开头公共部分
  16. 网络请求工具--AFNetworking 分类: ios技术 2015-02-03 08:17 76人阅读 评论(0) 收藏
  17. 用html5调取谷歌地图获取位置
  18. DeepLearning.ai学习笔记(三)结构化机器学习项目--week1 机器学习策略
  19. SQLServer之创建事务序列化
  20. Windows下安装配置Flutter

热门文章

  1. m_Orchestrate learning system---三十、项目中的dist文件一般是做什么的
  2. LeetCode--171--Excel表列序号
  3. codeforces 555a//Case of Matryoshkas// Codeforces Round #310(Div. 1)
  4. HDU2159二维背包
  5. POJ-3009 Curling 2.0 (DFS)
  6. 利用CNN进行流量识别 本质上就是将流量视作一个图像
  7. 共享内存创建shmget控制操作shmat,shmctl
  8. UVALive 2318 水题
  9. httpclient cookie相关介绍
  10. noip2005循环