School recruit Zhenti exercise pour 034 (Shell)

Pour

Subject description
should m liters of water poured into the same container as the n (assuming the container is large enough) to allow some capacity is empty, how many different ways there are to ask pour method? (Indicated by k) 5,1,1 and 1,5,1 1,1,5 and down is the same method.

Input Description :
The first line is the number of test data x (0≤x≤20). Each line contains the following two integers m and n, separated by spaces. 1≤m, n≤10.

Output Description :
for each row of data input m and n, one line corresponding output k.

 1 def func(m,n):
 2     if m == 1 or m == 0:
 3         return 1
 4     elif n == 1:
 5         return 1
 6     else:
 7         if n > m:
 8             n = m
 9         count = 0
10         for i in range(1,n+1):
11             if i == 1:
12                 count += func(m,i)
13             else:
14                 count += func(m-i,i)
15         return count
16 
17 def main():
18     s = int(input())
19     for i in range(s):
20         m,n = map(int,input().split())
21         print(func(m,n))
22 
23 
24 if __name__ == '__main__':
25     main()

It will not do.

Guess you like

Origin www.cnblogs.com/asenyang/p/11327728.html