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, the upper triangle and the lower triangular symmetry; reprint please specify Source: Search & Star Children topic Link: http://acm.hdu.edu.cn/showproblem.php?pid=2067
1#include <stdio.h>2 #defineLL __int643LL num[ $][ $]={0};4 voidInit ()5 {6 for(intI=1; i<= *; i++)7 {8num[i][0]=1;9 for(intj=1; j<i;j++)Tennum[i][j]=num[i][j-1]+num[i-1][j]; Onenum[i][i]=num[i][i-1]; A } - } - intMain () the { - intN,ca=1; - init (); - while(SCANF ("%d", &n)! =EOF) + { - if(n==-1) Break; +printf"%d%d%i64d\n", Ca++,n,2*num[n][n]); A } at return 0; - -}
The previous code is attached
#include <stdio.h> int main () { int i,j; __int64 a[36] = {1}; __int64 b[36] = {0}; for (i=1;i<36;i++) {for (j=1;j<i;j++) a[j]=a[j]+a[j-1]; B[I]=A[I]=A[I-1]; } For (J=1;SCANF ("%d", &i), i;j++) { if (i==-1) break ; else printf ("%d%d%i64d\n", J,i,2*b[i]); } return 0; }
Found now do the previous questions, think of some different ideas ...
Little Bunny's Chessboard (hdu2067)