答案

柯轶炜  •  1个月前


def count_combinations(T, test_cases): 
   results = [] 
   for n, m in test_cases: 
       count = 0 
       for one in range(0, n + 1): 
           for two in range(0, (n - one) + 1): 
               five = n - one - two 
               if one + 2 * two + 5 * five == m: 
                   count += 1 
       results.append(count) 
   return results 

T = int(input()) 
test_cases = [] 
for _ in range(T): 
   n, m = map(int, input().split()) 
   test_cases.append((n, m)) 

results = count_combinations(T, test_cases) 
for res in results: 
   print(res) 
 


评论: