The little bunny's chessboard.
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 7547 Accepted Submission (s): 4020
Problem Description Rabbit's uncle from the outside of the trip back to bring her a gift, the rabbit happy to run back to his room, opened a look is a chessboard, little rabbit disappointed. But not a few days found the board of fun. The shortest path from the starting point (0,0) to the end point (N,n) is C (2n,n), and now the rabbit wants to do so if it does not cross the diagonal (but can touch the grid point on the diagonal), how many paths are there? The rabbit thought for a long time did not think out, now want to ask you to help the rabbit to solve this problem, for you should not be difficult !
Input enters a number n (1<=n<=35) at a time, and when n equals-1 o'clock ends the input.
Output for each input data export path number, the specific format to see sample.
Sample input1312-1
Sample OUTPUT1 1 22 3 103 12 416024 test Instructions: from (0,0)---(n,n) ask you how many paths you have and do not cross the diagonal. Ideas: separated by diagonal, upper triangle and lower triangular symmetry;Reprint Please specify the Source:Looking for Children & stars Topic Links:http://acm.hdu.edu.cn/showproblem.php?pid=2067
#include <stdio.h> #define LL __int64ll num[36][36]={0};void init () {for (int i=1;i<=35;i++) { Num[i][0]=1; for (int j=1;j<i;j++) num[i][j]=num[i][j-1]+num[i-1][j]; NUM[I][I]=NUM[I][I-1];} } int main () { int n,ca=1; Init (); while (scanf ("%d", &n)!=eof) { if (n==-1) break; printf ("%d%d%i64d\n", Ca++,n,2*num[n][n]); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Little Bunny's Chessboard (hdu2067)