当前位置: 代码迷 >> 计算机英语 >> 英语达人
  详细解决方案

英语达人

热度:6502   发布时间:2013-02-26 00:00:00.0
求助英语达人
 
 
 Problem Statement for StrangeElevator 
 
 
Problem Statement 
  When cat Taro went to an internship, he found a strange elevator in the office's skyscraper. The skyscraper contains 58 floors. The elevator is composed of 2 boxes and these 2 boxes move together. When the lower box stops at the x-th floor, the upper box always stops at the (x+1)-th floor. The lower box stops only on odd floors (1st, 3rd, 5th, ..., 57th). The upper box stops only on even floors (2nd, 4th, 6th, ..., 58th). He is very interested by this elevator, and he wants to compute the number of possible elevators composed of N boxes in a skyscraper of height H. 

当猫太郎去实习,他发现他在办公室的摩天大楼奇怪的电梯。包含58层的摩天大楼。电梯是由2盒2盒,这些一起移动。当在X -楼下面的框停止时,总是在上部箱梁的(x +1)楼停止。下方的方块只停在奇数楼层(第一,第三,第五,...,57)。上层箱停在楼层甚至只(第二,四,六,...,第58次)。他是这个电梯很感兴趣,他希望来计算一个摩天大楼的高度H的盒子组成的N可能的电梯数量 





The elevators must satisfy the following conditions: 
For each floor, exactly one box stops at that floor. 
The distance between 2 boxes is an integer and never changes. More formally, for each pair of boxes (A,B), there must be some integer d such that box B always stops at the (x+d)-th floor when box A stops at the x-th floor. If the (x+d)-th floor doesn't exist, box A must not stop at the x-th floor. 
电梯必须满足以下条件:
对于每一个楼层,只有一个框停止在该楼层。
2盒之间的距离是一个整数,从不改变。更正式地说,每个盒(甲,乙)对,必须有整数d使得箱B总是在的(x+ D)的,楼时停止箱A在X-楼停止。如果(x+ D)的,楼不存在,箱A不能只停留在X-楼。




Two elevators are different if the following is true. When the bottommost box is at the first floor, there exists an i such that a box is at the i-th floor in one elevator and no box is at the i-th floor in the other elevator. You are given two integers H and N. Return the number of possible elevators that have N boxes in a skyscraper of height H, modulo 1,000,000,007.  
两部电梯是不同的,如果下面是真实的。当最底层箱一楼是,存在一个我这样的一个盒子是在我,在一个楼,没有电梯箱中的其他电梯i个楼。你是给定两个整数h和N.返回该有一个高度h,模1000000007摩天大楼ñ盒可能电梯数量
  
Definition 
  Class: StrangeElevator 
Method: theCount 
Parameters: int, int 
Returns: int 
Method signature: int theCount(int H, int N) 
(be sure your method is public) 
 
   
 
  
Constraints 
- H will be between 1 and 1,000,000,000, inclusive. 
- N will be between 1 and H, inclusive. 
  
Examples 
0)  
  58
 
2
 
 
Returns: 2
 
The following two elevators are possible: 
When the lower box stops at the 1st, 3rd, ..., 57th floor, the upper box stops at the 2nd, 4th, ..., 58th floor, respectively. 
When the lower box stops at the 1st, 2nd, ..., 29th floor, the upper box stops at the 30th, 31st, ..., 58th floor, respectively. 
 下面的两个电梯是可能的:
当下面的框在第1站,3,...,57楼,在第二,四,...,第58层上部箱梁站,分别为。
当在第一,第二,...,29楼下面的框停止,上面的框停止在第30,第31,...,第58楼,分别为。

 
 
1)  
  1
 
1
 
 
Returns: 1
 
The only box always stops at the 1st floor. 
 
 
2)  
  9
 
3
 
 
Returns: 2
 
The following two elevators are possible: 
When the lowest box stops at the 1st, the 4th and the 7th floor, the middle box stops at the 2nd, the 5th and the 8th floor, and the topmost box stops at the 3rd, the 6th and the 9th floor, respectively. 
When the lowest box stops at the 1st, the 2nd and the 3rd floor, the middle box stops at the 4th, the 5th and the 6th floor, and the topmost box stops at the 7th, the 8th and the 9th floor, respectively. 

下面的两个电梯是可能的:
当在第1,第4和第7层中最低的停止,在第2,第5和第8楼,最上面的框停止在第三,第六和第九层,中间的框中分别停止。
当在第一站中最低的,第2和第3层,位于第4,第5和第6楼中间的框中停止,并且在第7,第8和第9层,最上面的框分别停止。
  相关解决方案