"Recursion" put the apple

Source: Internet
Author: User

Problem: "Recursion" put the apple Title DescriptionChuji just took the oil to the kitchen, and mother shouted, "Go and wash the apples and put them on the plate." ”

Chuji to put m the same apples on n the same plate, allowing some plates to be empty, asking how many different ways are there? (denoted by K) 5, 1, 1 and 1, 5, 1 are the same kind of sub-method. InputThe 1th behavior is an integer that represents the number of test data (number of test data T (0≤t≤20), 2nd behavior m and N (M and N, separated by spaces. 1≤M,N≤10). Outputhow many different methods of output are there? Sample input
17 3
Sample output
8
#include <iostream>#include<cstdio>#include<cstring>using namespacestd;Const intN =2;intSlove (intMintN) {    if(M = =0|| n = =1)return 1; if(M < n)returnSlove (m,m); returnSlove (M-n, N) +slove (m,n-1); }intMain () {intT,m,n; scanf ("%d", &t);  while(t--) {scanf ("%d%d", &m, &N); printf ("%d\n", Slove (m,n)); }    return 0;}
View Code

"Recursion" put the apple

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.