NOIP2008 Universal group Pass Game (dynamic planning)--YHX

Source: Internet
Author: User

Title Description

When I was in P.E. class, little teacher often took the students with them to play games. This time, the teacher took the students together to do the passing game.

The rules of the game are like this: N students stand in a circle, one of the students holding a ball, when the teacher began to pass the whistle, each classmate can pass the ball to their own about two students of one (left or right), when the teacher in this blow whistle, pass stop, at this time, Holding the ball did not go out of the classmate is the loser, to show you a show.

The clever little guy raises an interesting question: how many different ways of passing can make the ball begin to pass in the small hand, pass the M-time, and return to the little brute hand. The two methods of passing are considered as different methods, and the sequence of the students receiving the ball in the order of catching is different when and only in these two methods. For example, there are three students 1th, 2nd, 3rd, and assume that the small is 1th, the ball passed 3 times back to the small hands of the way there are 1->2->3->1 and 1->3->2->1, a total of 2.

Input/output format

Input format:

The input file ball.in a common line with two integer n,m (3<=n<=30,1<=m<=30) separated by spaces.

output Format:

Output file Ball.out A total of one row, with an integer representing the number of methods that conform to test instructions.

1#include <cstdio>2 intdp[ *][ *];3 intMain ()4 {5     intI,j,k,m,n;6scanf"%d%d",&n,&m);7dp[0][1]=1;8      for(i=1; i<=m;i++)9     {Tendp[i][1]=dp[i-1][2]+dp[i-1][n]; Onedp[i][n]=dp[i-1][1]+dp[i-1][n-1]; A          for(j=2; j<n;j++) -dp[i][j]=dp[i-1][j-1]+dp[i-1][j+1]; -     } theprintf"%d\n", dp[m][1]); -}

Dynamic planning, now at point I, the last moment must be in i+1 or i-1.

Special treatment.

NOIP2008 Universal group Pass Game (dynamic planning)--YHX

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.