hdu2125之dp
来源:互联网 发布:广州办公软件培训班 编辑:程序博客网 时间:2024/06/02 21:16
Local area network
Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 410 Accepted Submission(s): 101
Problem Description
A local area network (LAN) supplies networking capability to a group of computers in close proximity to each other such as in an office building, a school, or a home. A LAN is useful for sharing resources like files, printers, games or other applications. A LAN in turn often connects to other LANs, and to the Internet or other WAN.
In this contest, everybody is connecting with each others like the following figure.
The contest’s network was built as N rows and M columns, your computer locate at (0, 0) and the judger’s computer locate at (m-1, n-1) The code you submit would only transfer to up or right smoothly. It doesn’t matter if some accidents happened. Could you tell me how many ways from your computer to judger when a data wire was broken?
In this contest, everybody is connecting with each others like the following figure.
The contest’s network was built as N rows and M columns, your computer locate at (0, 0) and the judger’s computer locate at (m-1, n-1) The code you submit would only transfer to up or right smoothly. It doesn’t matter if some accidents happened. Could you tell me how many ways from your computer to judger when a data wire was broken?
Input
There are multiple cases. Every case contains two integers in the first line, N, M (3<=N+M<=40). Second line contains four integers X1, Y1, X2, Y2 (0<=X1, X2<M, 0<=Y1, Y2<N, |X1+Y1-X2-Y2|=1), meaning the broken wire position.
Output
Print the answer in one line.
Sample Input
3 30 0 1 0
Sample Output
3
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<queue>#include<algorithm>#include<map>#include<iomanip>#define INF 99999999using namespace std;const int MAX=40+10;int dp[MAX][MAX];bool mark[MAX][MAX];int main(){int n,m,x1,y1,x2,y2;while(cin>>n>>m){memset(mark,false,sizeof mark);cin>>x1>>y1>>x2>>y2;dp[0][1]=1;mark[y1+1][x1+1]=mark[y2+1][x2+1]=true;for(int i=1;i<=n;++i){for(int j=1;j<=m;++j){dp[i][j]=dp[i-1][j]+dp[i][j-1];if(mark[i][j] && mark[i-1][j])dp[i][j]-=dp[i-1][j];if(mark[i][j] && mark[i][j-1])dp[i][j]-=dp[i][j-1];}}cout<<dp[n][m]<<endl;}return 0;}
- hdu2125之dp
- hdu2125
- DP专辑之线性DP
- DP专题之概率DP
- DP之Brackets Sequence
- DP之旅
- hdu2845之Beans,DP
- hdu2089之数位dp
- hdu4507之数位DP
- hdu2870之DP
- hdu1494之dp
- hdu4734之数位dp
- hdu4714之树形DP
- hdu1561之树形dp
- poj1155之树形DP
- hdu1011之树形dp
- hdu1520之树形dp
- Android开发之dp
- 多校第三场总结
- xml的另一个助手——schema
- Android TextView高级特性使用
- android中layout_weight的理解
- 如何自定义网站404页面以及网站logo
- hdu2125之dp
- usb blaster in win7
- Http和Socket连接区别
- Java语言实现简单FTP软件------>FTP软件主界面的实现(四)
- 后缀表达式二
- HttpRuntime的认识与加深理解
- 破解cisco路由enable密码
- JDK1.5新特性随手记
- C#中访问修饰符的使用