fork download
  1. import sys
  2.  
  3. def bouquets(narcissus_price, tulip_price, rose_price, summ):
  4. prices = sorted([narcissus_price, tulip_price, rose_price], reverse=True)
  5. pr_b = prices[0]
  6. pr_s = prices[1]
  7. pr_m = prices[2]
  8. rb = int(summ / pr_b) + 1
  9. rs = int(summ / pr_s) + 1
  10. rm = int(summ / pr_m) + 1
  11. counter = 0
  12. for b in range(rb):
  13. sb = b * pr_b
  14. for s in range(rs):
  15. ss = s * pr_s
  16. if ss + sb > summ: break
  17. for m in range(rm):
  18. sm = m * pr_m
  19. pr = sb + ss + sm
  20. if pr > summ: break
  21. if pr <= summ and (b + s + m) % 2 != 0:
  22. counter += 1
  23. return counter
  24.  
  25. print bouquets(200,300,400,100000) # 3524556
Success #stdin #stdout 0.33s 45072KB
stdin
Standard input is empty
stdout
3524556