"Recursion" put the apple Title Description Chuji 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. Enter the 1th behavior 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). How many different sub-methods are available for output output. Sample input
17 3
Sample output
8
Analysis: A kind of ball box problem;
If you are using a K-plate, put an apple on the K-plate, or convert it to a K-1 plate;
#include <iostream>#include<cstdio>#include<cstdlib>#include<cmath>#include<algorithm>#include<climits>#include<cstring>#include<string>#include<Set>#include<map>#include<queue>#include<stack>#include<vector>#include<list>#defineRep (I,m,n) for (i=m;i<=n;i++)#defineRSP (It,s) for (Set<int>::iterator It=s.begin (); It!=s.end (); it++)#defineMoD 1000000007#defineINF 0x3f3f3f3f#defineVI vector<int>#definePB Push_back#defineMP Make_pair#defineFi first#defineSe Second#definell Long Long#definePi ACOs (-1.0)Const intmaxn=1e6+Ten;Const intdis[][2]={0,1,-1,0,0,-1,1,0};using namespacestd;ll gcd (ll p,ll q) {returnq==0? P:GCD (q,p%q);} ll Qpow (ll p,ll q) {ll F=1; while(q) {if(q&1) f=f*p%mod;p=p*p%mod;q>>=1;}returnF;} ll Dfs (intAintp) { if(a<=1|| p<=1)return 1; Else if(a<p)returnDFS (A,A); Else returnDFS (A-P,P) +dfs (a,p-1);}intMain () {inti,j,m,n,k,t; scanf ("%d",&t); while(t--) {scanf ("%d%d",&m,&N); printf ("%lld\n", DFS (m,n)); } //System ("pause"); return 0;}
"Recursion" put the apple