2718: Move the course (another one to put the apples)

Source: Internet
Author: User

2718: Move Route

    • View
    • Submit
    • Statistics
    • Questions

Total time limit:

1000ms

Memory Limit:

65536kB

Describe

x table has a M row n column of the grid matrix, each square with coordinates, row coordinates from bottom to top, increment, column coordinates from left to right, the coordinates of the lower left Square is (m,n), then the upper right square coordinates are ().
Xiao Ming is a naughty boy, one day he caught an ant, accidentally hurt the right foot of the ant, so ants can only move up or to the right. Xiao Ming put the ant in the lower left corner of the square, the ants from
In the lower left corner, move to the upper-right corner of the grid, moving a square each step. Ants always move within the grid matrix, please calculate the number of different moving routes.
For a grid of 1 rows and 1 columns, the ant moves in situ, the number of moving routes is 1, and for a grid of 1 rows, 2 columns (or 2 rows, 1 columns), the ant only has to move right (or up) one time, and the number of moving routes is 1 ... For a 2-row, 3-column grid matrix, as shown:

-------------------
| (2,1) | (2,2) | (2,3) |
-------------------
| (a) | (from) | (1,3) |
-------------------

There are 3 types of mobile routes for ants:
Route 1: (a) → (1,3) → (2,3)
Route 2: (a) → (2,2) → (2,3)
Route 3: (a) → (2,1) → (2,2) → (2,3)

Input

Enter only one row, including two integers m and n (0<m+n<=20), representing the number of rows and columns of the grid matrix, separated by spaces between M and N

Output

The output is only one row, which is the number of different moving routes.

Sample input

2 3

Sample output

3

#include <cstdio>#include<iostream>#defineRef (I,X,Y) for (register int i=x;i<=y;i++)using namespacestd;inta[ the][ the];//represents the number of scenarios to 1,1->i,jintn,m;intMain () {//freopen ("sh.in", "R", stdin);scanf"%d%d",&n,&m); refI1, Max (n,m)) a[i][1]=1, a[1][i]=1; refI2, N)ref(J,2, M) a[i][j]=a[i-1][j]+a[i][j-1]; printf ("%d\n", A[n][m]); return 0;}

2718: Move the course (another one to put the apples)

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.