Escape Problem
来源:互联网 发布:java socket传输类 编辑:程序博客网 时间:2024/06/11 13:34
- 题目描述
Hamilton, the famous thief, plans a bank robbery in L.A. When searching for the escape route, he takes two main factors into consideration. First, he cannot pass through any intersection twice since the police will set up force at any intersection after he passes it for the first time. Second, as, in America, vehicles are driven on the right side, it is too risk for Hamilton to take a left turn at intersections when escaping. So he will always drive straight ahead or turn right when he comes to a intersection.
Hamilton is planning his escape route. He pays you, his partner, to calculate the number of different ways which leads him to his shelter. He gives you the map of the city, which looks like grids, with only streets leading in East-West direction and South-North direction. His starting position is (0, 0) which is the South-West corner of the city and his shelter is located at (x, y) which stands for the intersection of the (x+1)th South-North direction street and the (y+1)th East-Wesst direction street. Moreover, when he starts at (0, 0), he is heading north, and of course, he can make a right turn there as well.
As the total number of different ways might be very large, you are asked to give the number's residue modulo 100000007.
- 输入
The first line of input contains N (N <=100), the number of test cases. Each of the following lines describes one test case. Each line consists of four integers, X, Y, x, y(0<X,Y≤2000, 0≤x≤X, 0≤y≤Y), which (X, Y) is the North-East corner of the city and (x, y) is the location of Hamilton's shelter. The famous thief, of course, cannot driver out of the city.
- 输出
For each test case, print one line with a single integer which is the corresponding answer.
- 样例输入
3
3 4 0 0
3 4 1 0
3 4 1 1- 样例输出
1
13
16- The following is my answer
- 这是一个递归的问题, 计算的时候每次对 (x + 1, y) , (x + 2, y) .... (X, y) 为参考原点 (0,0) 生成新的坐标系作递归计算。
- Escape Problem
- escape
- escape
- escape
- Escape
- Escape
- Escape
- HOJ 1016 Joseph's problem I&&HOJ 2920 Escape
- 福州大学第十二届程序设计竞赛 Problem G Escape
- (BFS)福州大学12th,Problem 2196 Escape
- javaScript:Escape()
- escape() 方法:
- escape sequence
- Escape Sandy
- Escape Rout
- JS escape
- js escape
- Escape Sequences
- 80后的通病 【转】
- VB.Net程序设计:快速填充图片到Excel文件里面
- asp 中 mid函数的用法
- 使用putty+xming远程桌面管理linux系统
- 3.2如何选择是在 视图类 还是在 视图的框架窗口类 内实现某种特殊行为?
- Escape Problem
- 太晚睡觉等于自杀
- jpg图片在firefox正常显示 在ie不能显示
- 好书总览
- 从dll导出lib (原文地址:http://blog.csdn.net/tingsking18/archive/2010/03/18/5394466.aspx)
- 简单的 DataView
- Spring Javamail使用
- Sql 根据名称剔除重复数据、根据id返回最新的
- C#调用Server Soap接口MaxArrayLength和MaxStringContentLength错误解决