SHARE
TWEET

Untitled

a guest Jun 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from math import ceil
  2.  
  3. water1, water2, sugar1, sugar2, saturated, max_amount = map(int, input().split(' '))
  4.  
  5. max_rate = 0
  6. result_amount = 0
  7. result_sugar = 0
  8.  
  9. for i in range(ceil(max_amount / sugar1 + saturated) + 1):
  10.     for j in range(ceil(max_amount / sugar2 + saturated) + 1):
  11.         sugar = i * sugar1 + j * sugar2
  12.         if sugar > max_amount:
  13.             break
  14.         if sugar + sugar * 100 / saturated > max_amount:
  15.             break
  16.         for k in range(ceil(max_amount / water1) + 1):
  17.             if water1 * 100 * k > max_amount:
  18.                 break
  19.             for l in range(ceil(max_amount / water2) + 1):
  20.                 water = k * water1 * 100 + l * water2 * 100
  21.                 if sugar + water > max_amount:
  22.                     break
  23.                 if not water:
  24.                     continue
  25.                 rate = sugar / water
  26.                 if rate > saturated / 100:
  27.                     continue
  28.                 if rate > max_rate:
  29.                     max_rate = rate
  30.                     result_amount = sugar + water
  31.                     result_sugar = sugar
  32. print('{amount} {sugar}'.format(amount=result_amount, sugar=result_sugar))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top