Hdustm4 basketball dream

Source: Internet
Author: User

Question: omitted

Analysis: memory-based search

Use DP [I] [J] to indicate that the number of I attacks is less than J.

Hdustm4

# Include <iostream> # Include <Algorithm> # Include <Stdio. h> # Include <Stdlib. h> # Include < String . H> Using   Namespace  STD;  Const   Int N =20 + 5  ;  Const   Int M = 600 + 10  ;__ Int64 f [N] ;__ int64 DP [N] [m];  Int S [ 3 ] = { 1 , 2 , 3  };  Void Init () {f [  0 ] = 1  ; F [  1 ] = 3  ;  For ( Int I = 2 ; I <n; ++ I) f [I] = F [I- 1 ] * 3  ; }__ Int64 DFS (  Int Depth, Int  Score ){  If (DP [depth] [score]! =- 1  )  Return  DP [depth] [score];  If (Depth = 1  ){  Int Sum = 0  ;  For ( Int I =0 ; I < 3 ; ++ I)  If (Score> S [I]) ++ SUM;  Return DP [depth] [score] = SUM;} _ int64 RET = 0  ;  For ( Int I = 0 ; I <3 ; ++ I ){  If (Score> S [I]) RET + = DFS (depth- 1 , Score- S [I]);}  Return DP [depth] [score] = RET ;}  Int  Main (){  Int  A, B, T; Init ();  While (Scanf ( " % D  " , & A, & B, & T) = 3  ){  Int TOT = T/ 15  ; B + = TOT/ 2  ;  Int N = tot-tot/ 2 ; //  Number of times we can attack          Int M = B-A +1 ; //  We scored less than Team B          If (M <= 0 ){ //  Win Printf ( "  % I64d \ n  "  , F [N]);  Continue  ;}  If (M> N * 3 ) {Printf (  "  0 \ n  "  );  Continue  ;} Memset (DP, - 1 , Sizeof  (DP); printf (  "  % I64d \ n  " , F [N]- DFS (n, m ));}  Return  0  ;} 

 

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.