Rabbit Board (hdu2067) and rabbit board hdu2067

Source: Internet
Author: User

Rabbit Board (hdu2067) and rabbit board hdu2067
Rabbit Board

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 7547 Accepted Submission (s): 4020


Problem Description the uncle of the rabbit came back from outside to bring her a gift. The rabbit happily ran back to his room and opened a 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!

 

Input n (1 <= n <= 35), and end the Input when n is equal to-1.

 

For the number of Output paths for each input data, see Sample for the specific format.

 

Sample Input1312-1

 

Sample Output1 1 22 3 103 12 416024 question: (0, 0) --- (n, n) ask you how many paths there are; do not pass through the diagonal line. Train of Thought: separated by diagonal lines, triangle and triangle symmetric; reprinted please indicate the source: Looking for and star child question link: http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 2067

 

 

 1 #include<stdio.h> 2 #define LL __int64 3 LL num[36][36]={0}; 4 void init() 5 { 6     for(int i=1;i<=35;i++) 7     { 8         num[i][0]=1; 9         for(int j=1;j<i;j++)10             num[i][j]=num[i][j-1]+num[i-1][j];11         num[i][i]=num[i][i-1];12     }13 }14 int main()15 {16     int n,ca=1;17     init();18     while(scanf("%d",&n)!=EOF)19     {20         if(n==-1) break;21         printf("%d %d %I64d\n",ca++,n,2*num[n][n]);22     }23     return 0;24 25 }

 

 

 

 

Add previous Code

#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;  }  

I found that my previous questions are different in thinking...

 

 

Related Article

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.