You are viewing a single comment's thread. Return to all comments →
from itertools import combinations_with_replacement def stones(n, a, b): ans = set() diff_perm = combinations_with_replacement((a, b), n-1) for i in diff_perm: ans.add(sum(i)) return sorted(ans) T = int(input()) while (T > 0): n = int(input()) a = int(input()) b = int(input()) result = stones(n, a, b) print(*result) T -= 1
Seems like cookies are disabled on this browser, please enable them to open this website
Manasa and Stones
You are viewing a single comment's thread. Return to all comments →
for Python3 Platform