#42852: python


suyueh (suyueh)

School : No School
ID : 272111
IP address : [101.10.92.236]
Last Login :
2025-01-13 19:53:09
b511. 換銅板 -- 清華 MOOCs 2014 程式設計導論期末考 | From: [125.229.229.84] | Post Date : 2024-10-08 18:51

while True:
  try:
    n = int(input())
    coin = [int(i) for i in input().split()]
    mx = int(input())
    r = []
    def fn(f):
      h = len(f)
      if h == n:
        if sum([a*b for a, b in zip(f, coin)]) == mx:
          r.append(f)
        return
      for i in range(mx//coin[h]+1): fn(f+[i])
    fn([])
    r.sort()
    for i in r:
      print('(', end='')
      print(*i, sep =',', end=')')
      print()
  except:
    break
 
ZeroJudge Forum