HDU rabbit Board

Source: Internet
Author: User
Rabbit Board
Time Limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 154 accepted submission (s): 102
Problem descriptionThe uncle of the rabbit came back from outside and brought her a gift. The rabbit happily ran back to his room and opened the board. The rabbit was disappointed. But a few days later I found the fun of the Board. The number of shortest paths from the start point (0, 0) to the end point (N, N) is C (2n, n ), now, the rabbit wants to determine the number of such paths without traversing the diagonal line (but can touch the grid points on the diagonal line? I have never thought about it for a long time. Now I want to ask you to help me solve this problem. It should be difficult for you! 
InputInput N (1 <= n <= 35) at a time, and end the input when n is equal to-1. 
OutputFor the number of output paths for each input data, see sample for the specific format. 
Sample Input
1312-1
 
Sample output
 
1 1 22 3 103 12 416024

uncle bunny came back from outside and brought her a gift, the rabbit happily ran back to himself
the room was displayed as a chessboard, rabbit was disappointed. However, a few days later I found the game
the fun of the disk. The number of shortest paths from the start point (0, 0) to the end point (N, N) is C (2n, n),
now, the rabbit wants to avoid crossing the diagonal line (but can touch the points on the diagonal line ), this path
How many paths are there? There are 2 * C (n) types in total. C (n) is the number of catlands

ImportJava.Math.Bigdecimal;
Import
Java.Util.Bytes;

Public class Main {
Public static
Void Main ( String [] ARGs ){
Bigdecimal
[] T = New Bigdecimal [ 36 ];
Bigdecimal
N , B ;
Int
K , J = 1 ;
Bytes
CIN = New Bytes ( System . In );
T [ 1 ] = Bigdecimal . Valueof ( 1 );
For
( Int I = 2 ; I < 36 ; I ++ ){
N=Bigdecimal.Valueof(I);
B=Bigdecimal.Valueof(4).Multiply(N);
B=B.Subtract(Bigdecimal.Valueof(2));
N=N.Add(Bigdecimal.Valueof(1));
B=B.Multiply(T[I-1]);
T[I] =B.Divide(N);
// System. Out. println (T [I]);
}
While
(CIN.Hasnext()){
K = CIN. Nextint ();
If
( K =- 1 ) Break ;
System
. Out . Println ( J + "" + K + "" + T [ K ]. Multiply ( Bigdecimal . Valueof ( 2 )));
J++;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.