Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
124072 柯轶炜 统计硬币 Python3 Accepted 119 MS 3764 KB 576 2025-07-10 22:25:51

Tests(1/1):


Code:

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)