Symbol triangle (hdu 2510 search + play table)

Source: Internet
Author: User

Symbol triangles

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1246 Accepted Submission (s): 664


The 1th line of the problem description symbol triangle has n a symbol consisting of "+" and "-", with 1 fewer symbols per line, and 2 under the same number as "+", and 2 different numbers under "-". Calculates how many different symbol triangles have the same number of "+" and "-". The 1 symbol triangles at N=7 are as follows:
+ + - + - + +
+ - - - - +
- + + + -
- + + -
- + -
- -
+

Input 1 positive integers per line n <=24,n=0 exit.

The number of outputn and symbol triangles.

Sample Input151619200 Sample Output15 189616 516019 3275720 59984 play the table code:
1#include <iostream>2#include <cstring>3#include <cstdio>4 using namespacestd;5 inta[ -];6 Charres[ -][ -];7 intsum;8 BOOLCountintN)9 {Ten     intp1=0, p2=0; One     inti,j; A      for(i=1; i<=n;i++) -     { -         if(res[0][i]=='+') p1++; the         Elsep2++; -     } -      for(intI=1; i<n;i++) -          for(j=1; j<=n-i;j++) +         { -Res[i][j]= (res[i-1][j]==res[i-1][j+1]?'+':'-'); +             if(res[i][j]=='+') p1++; A             Elsep2++; at         } -     if(p1==p2) -         return 1; -     return 0; - } - voidDfsintNints) in { -     inti,j; to     if(s>N) +     { -         if(count (n)) thesum++; *         return; $     }Panax Notoginsengres[0][s]='+'; -DFS (n,s+1); theres[0][s]='-'; +DFS (n,s+1); A     return; the } + intMain () - { $     intN; $     inti,j; -a[1]=a[2]=0; -      for(i=1; i<= -; i++) the     { -sum=0;WuyiDFS (I,1); thea[i]=sum; -cout<<a[i]<<Endl; Wu     } -}

Symbol triangle (hdu 2510 search + hit table)

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.