Problem:
 Score : 300 points    Problem Statement Snuke is making sugar water in a beaker.
Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.   Operation 1: Pour 100A grams of water into the beaker.  Operation 2: Pour 100B grams of water into the beaker.  Operation 3: Put C grams of sugar into the beaker.  Operation 4: Put D grams of sugar into the beaker.   In our experimental environment, E grams of sugar can dissolve into 100 grams of water.  Snuke will make sugar water with the highest possible density.  The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.
Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.
If there is more than one candidate, any of them will be accepted.  We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent.
Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.      Constraints  1 \leq A < B \leq 30  1 \leq C < D \leq 30  1 \leq E \leq 100  100A \leq F \leq 3  000  A , B , C , D , E and F are all integers.         Inputs Input is given from Standard Input in the following format:  A  B  C  D  E  F       Outputs Print two integers separated by a space.
The first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.        Sample Input 1 1 2 10 20 15 200      Sample Output 1 110 10  In this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.  We can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.
It is not possible to make sugar water with higher density.
For example, the following sequences of operations are infeasible:   If we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.  If we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.        Sample Input 2 1 2 1 2 100 1000      Sample Output 2 200 100  There are other acceptable outputs, such as:  400 200  However, the output below is not acceptable:  300 150  This is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.       Sample Input 3 17 19 22 26 55 2802      Sample Output 3 2634 934

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
cmax = 0
x = 100*A
y = 0
for n in range(F//(100*A)+1):
    for m in range((F-n*100*A)//(100*B)+1):
        for l in range((F-n*100*A-m*100*B)//C+1):
            for k in range((F-n*100*A-m*100*B-l*C)//D+1):

                if n**2+m**2>0 and l*C+k*D<=E*(n*A+m*B):

                    if cmax<(l*C+k*D)/(n*100*A+m*100*B+l*C+k*D):
                        cmax = (l*C+k*D)/(n*100*A+m*100*B+l*C+k*D)
                        x = n*100*A+m*100*B
                        y = l*C+k*D
                    
print(x+y,y)

Solution (Python):
a, b, c, d, e, f = map(int,input().split( ))
mx = 0
ans = [0,0]
for i in range(f//(a*100)+1):
    sup_b = f-i*a*100
    
    for j in range(sup_b//(b*100)+1):
        wat = i*a*100 + j*b*100
        
        if wat > f or not wat:
            continue
        sup_sug = min(e*(wat/100), f - wat)

        
        for k in range(int(sup_sug//c)+1):
            l = (sup_sug - k*c)//d
            
            if (k*c + l*d)/wat > e/100:
                continue
                
            if mx < (k*c + l*d)/wat:
                mx = (k*c + l*d)/wat
                ans = [(k*c + l*d) + wat, k*c + l*d]
if int(ans[0])==0 and int(ans[1])==0:
    print(100*a,0)
else:
    print(int(ans[0]),int(ans[1]))

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    A, B, C, D, E, F = map(int, input().split())
    waters = set()
    sugars = set()
    for a in range(0, F+1, 100 * A):
        for b in range(0, F+1, 100 * B):
            if a + b <= F:
                waters.add(a + b)
            else:
                break
    for c in range(0, F+1, C):
        for d in range(0, F+1, D):
            if c + d <= F:
                sugars.add(c + d)
            else:
                break
    waters = sorted(list(waters))[1:]
    sugars = sorted(list(sugars))
    
    ans = 0
    ans_w = 0
    ans_s = 0
    for w in waters:
        for s in sugars:
            if w + s <= F:
                if s <= (w//100) * E:
                    tmp = (100 * s)/(w + s)
                    
                        
                    if tmp >= ans:
                        ans = tmp
                        ans_w = w
                        ans_s = s
            else:
                break
    print(ans_w + ans_s, ans_s)

if __name__ == "__main__":
    main()

Solution (Python):
def solve():
    A, B, C, D, E, F = map(int, input().split())
    A, B = 100 * A, 100 * B
    waters = set()
    sugars = set()
    for i in range(3001):
        for j in range(3001):
            if A * i + B * j <= F:
                waters.add(A * i + B * j)
            if C * i + D * j <= F:
                sugars.add(C * i + D * j)
    ans_per = 0
    ans_water = 0
    ans_sugar = 0
    for w in waters:
        if w == 0:
            continue
        for s in sugars:
            if w + s <= F and ans_per <= s / w <= E / 100:
                ans_per = s / w
                ans_water = w
                ans_sugar = s
    print(ans_water + ans_sugar, ans_sugar)


if __name__ == '__main__':
    import datetime
    
    solve()

Solution (Python):
a,b,c,d,e,f = map(int,input().split())

total = 0
sugar = 0
max_concentration = 0

for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        for k in range(f//c+1):
            for l in range(f//d+1):
                if 0 < 100*(a*i+b*j)+(c*k+d*l)<=f and c*k+d*l<=e*(a*i+b*j):
                    if max_concentration <= (c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l)):
                        max_concentration = (c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l))
                        total = 100*(a*i+b*j)+(c*k+d*l)
                        sugar = (c*k+d*l)
print(total,sugar)

Solution (Python):
a, b, c, d, e, f = map(int,input().split( ))
mx = 0
ans = [0,0]
for i in range(f//(a*100)+1):
    sup_b = f-i*a*100
    
    for j in range(sup_b//(b*100)+1):
        wat = i*a*100 + j*b*100
        
        if wat > f or not wat:
            continue
        sup_sug = min(e*(wat/100), f - wat)

        
        for k in range(int(sup_sug//c)+1):
            l = (sup_sug - k*c)//d
            
            if (k*c + l*d)/wat > e/100:
                continue
                
            if mx < (k*c + l*d)/wat:
                mx = (k*c + l*d)/wat
                ans = [(k*c + l*d) + wat, k*c + l*d]
if int(ans[0])==0 and int(ans[1])==0:
    print(100*a,0)
else:
    print(int(ans[0]),int(ans[1]))

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
A *= 100
B *= 100
check = -1
for i in range(F//A+1):
    for j in range((F-(A*i))//B+1):
        if i == 0 and j == 0:continue
        for k in range((F-(A*i)-(B*j))//C+1):
            for l in range((F-(A*i)-(B*j)-(C*k))//D+1):
                water = A*i+B*j
                sugar = C*k+D*l
                if sugar > water//100*E:continue
                if check < sugar / (water+sugar):
                    check = sugar / (water+sugar)
                    ans = [water+sugar,sugar]
print(*ans)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
A *= 100
B *= 100
check = -1
for i in range(F//A+1):
    for j in range((F-(A*i))//B+1):
        if i + j == 0:continue
        for k in range(((F-(A*i))-B*j)//C+1):
            for l in range((((F-(A*i))-B*j)-C*k)//D+1):
                water = A*i+B*j
                sugar = C*k+D*l
                if water//100*E < sugar:continue
                if check < 100*sugar/(water+sugar):
                    check = 100*sugar/(water+sugar)
                    ans = [water+sugar,sugar]
print(*ans)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
A = A * 100
B = B * 100
ans = [0, 0]
den = 0

def dence(a,b,c,d):
  return a*A+b*B+c*C+d*D


for a in range(F//A+1):
  for b in range(F-a*100//B+1):
    for c in range((F-a*A-b*B)//C+1):
      for d in range((F-a*A-b*B-c*C)//D+1):
        if (a*A+b*B)*E/100 >= c*C+d*D and any(i for i in [a,b,c,d]):
          
          if 100*(c*C+d*D)/(a*A+b*B+c*C+d*D) > den:
            
            den = 100*(c*C+d*D)/(a*A+b*B+c*C+d*D)
            
            ans = [a*A+b*B+c*C+d*D, c*C+d*D]
if ans[1]:
  print(ans[0], ans[1])
else:
  print(A, 0)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in reversed(range(max_sugar // C + 1)):
        for k in reversed(range((max_sugar - j * C) // D + 1)):
            sugar = max(sugar, j * C + k * D)
            if max_sugar == sugar:
                break
        else:
            continue
        break
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

print(' '.join(map(str, ans)))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in reversed(range(max_sugar // C + 1)):
        for k in range((max_sugar - j * C) // D + 1):
            sugar = max(sugar, j * C + k * D)
            if max_sugar == sugar:
                break
        else:
            continue
        break
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

print(' '.join(map(str, ans)))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in range(max_sugar // C + 1):
        for k in range((max_sugar - j * C) // D + 1):
            sugar = max(sugar, j * C + k * D)
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

print(' '.join(map(str, ans)))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = [0]
    for j in range(max_sugar // C + 1):
        for k in range((max_sugar - j * C) // D + 1):
            sugar.append(j * C + k * D)
    max_sugar = max(sugar)
    concentration = max_sugar / (i + max_sugar)
    if c < concentration:
        c = concentration
        ans = [i + max_sugar, max_sugar]

print(' '.join(map(str, ans)))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
ans = [100 * A, 0]
c = 0

for i in range(1, F // (100 * A) + 1):
    for j in range((F - 100 * A * i) // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        for k in range((F - a) // C + 1):
            for l in range((F - a - C * k) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

print(' '.join(map(str, ans)))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
ans = [100 * A, 0]
c = 0

for i in range(1, F // (100 * A) + 1):
    for j in range((F - 100 * A * i) // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a - C * k) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b and a + b <= F:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

print(' '.join(map(str, ans)))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
ans = [100 * A, 0]
c = 0

for i in range(1, F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b and a + b <= F:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

print(' '.join(map(str, ans)))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
c = []
ans_list = []

for i in range(1, F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a) // D + 1):
                b = k * C + l * D
                if (A * i + B * j) * E >= b and a + b <= F:
                    c.append(100 * b / (a + b))
                    ans_list.append([a + b, b])
                else:
                    break

ans = ans_list[c.index(max(c))]

print(' '.join(map(str, ans)))

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
checklist=[]
for num1 in range(f//(100*a)+1):
    for num2 in range((f//100*b)+1):
        
        if (100*a)*(num1)+(100*b)*(num2)<=f and [num1,num2]!=[0,0] and (100*num1)*a+(100*num2)*b not in checklist:
            checklist.append((100*num1)*a+(100*num2)*b)
sugarlist=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)           
sugarlist .append(0)
maxsugar=0
ratio=-1
good=0           
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*x<=e*y:
            if x/y>=ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
V = 0
ans = ()
for i in range(F//(A*100)+1):
  for j in range(F//(B*100)+1):
    m = A*i + B*j
    m = m*100
    if m>F or m==0:
      continue
    lim = min(m*E//100, F-m)
    
    l = lim
    w = 0
    z = 0
    for x in range(lim//C+1):
      for y in range(lim//D+1):
        n = x*C+y*D
        if n>lim:
          continue
        if lim-n<l:
          l = lim-n
          w = x
          z = y
    s = w*C+z*D
    v = 100*s/(m+s)
    if v>=V:
      ans = (m+s,s)
      V = v
print(*ans)

Solution (Python):
a, b, c, d, e, f = map(int, input().split())

waters = []
sugars = []

for w in range(f // 100):
    for i in range(0, w+1, a):
        if (w - i) % b == 0:
            waters.append(w)
            break
for s in range(f):
    for i in range(0, s+1, c):
        if (s - i) % d == 0:
            sugars.append(s)
            break

answ = a
anss = 0

for w in waters:
    for s in sugars:
        if 100 * w + s > f:
            continue
        if s > e * w:
            continue
        if w == 0:
            continue
        if s / w > anss / answ:
            answ = w
            anss = s
print(answ*100+anss, anss)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
ans_sw = 1
ans_s = 0
for a in range(F//(100*A)+1):
  for b in range(F//(100*B)+1):
    if 100*A*a + 100*B*b > F or 100*A*a+100*B*b == 0:
      continue
    for c in range((A*a+B*b)*E+1):
      for d in range((A*a+B*b)*E+1):
        sw = 100*A*a+100*B*b+C*c+D*d
        s = C*c+D*d
        if 0 < sw <= F and s <= (A*a+B*b)*E and ans_s/ans_sw < s/sw:
          ans_s = s
          ans_sw = sw
if ans_sw == 1:
  print(100*A ,0)
else:
  print(ans_sw, ans_s)

Solution (Python):
from collections import defaultdict
A, B, C, D, E, F = [int(x) for x in input().split()]
A *= 100
B *= 100
d = defaultdict(lambda: False)
d2 = defaultdict(lambda: False)
dd2 = defaultdict(lambda: False)

ret = [0, min(A, B), 0]

def dp2(w, s):
  global ret
  total_weight = w + s
  if dd2[(w, s)] != False:
    return d2[(w, s)]
  else:
    dd2[(w, s)] = True
  if (s / w) > E / 100:
    d2[(w, s)] = 0
    return 0
  else:
    d2[(w, s)] = 100 * s / (s + w)
    if d2[(w, s)] > ret[0]:
      ret = [d2[(w, s)], w + s, s]
  if total_weight + C <= F:
    dp2(w, s + C)
  if total_weight + D <= F:
    dp2(w, s + D)
  
def dp(w):
  if d[w]:
    return 0
  dp2(w, 0)
  d[w] = True
  if w + A <= F:
    dp(w + A)
  if w + B <= F:
    dp(w + B)
  return 0

dp(min(A, B))
print(ret[1],ret[2])

Solution (Python):
A, B, C, D, E, F = map(int, input().split(' '))
maxconc = 0.0
maxwater = 100*A
maxsugar = 0

for i in range(F//(100*A)+1):
  for j in range((F-100*A*i)//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print('{0} {1}'.format(maxwater+maxsugar,maxsugar))

Solution (Python):
A, B, C, D, E, F = map(int, input().split(' '))

max_sugar = 0
max_water = 100*A
max_conc = 0.0
A_limit = F // (100*A)
for i in range(A_limit + 1):
    B_limit = (F-100*A*i) // (100*B)
    for j in range(B_limit + 1):
        if i == 0 and j == 0:
            continue
        sugar_limit = min(E * (A*i+B*j), F-100*(A*i+B*j))

        sugar_ = 0
        for c in range(sugar_limit//C + 1):
            d = (sugar_limit-c*C)//D
            temp_sugar = c*C + d*D
            sugar_ = max(sugar_, temp_sugar)
        temp_conc = sugar_/(sugar_+100*(A*i+B*j))
        if temp_conc > max_conc:
            max_conc = temp_conc
            max_water = 100*(A*i + B*j)
            max_sugar = sugar_
print('{0} {1}'.format(max_water+max_sugar, max_sugar))

Solution (Python):
A,B,C,D,E,F = map(int,input().split())

maxs = 0
maxw = 1
for i in range(0,F//100+1,B):
  for j in range(0,F//100-i+1,A):
    if i+j == 0:
      continue
    w = (i+j)*100
    for k in range(0,min(F-w,E*w//100)+1,D):
      l = min((F-w-k)//C * C,(E*w//100-k)//C * C)
      s = k+l
      
      if maxs/(maxs+maxw) <= s/(s+w):
        maxs = s
        maxw = w
print(maxs+maxw,maxs)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
water,k,l = set(),1,1

while k * A * 100 <= F:
    water.add(k * A * 100)
    k += 1
while l * B * 100 <= F:
    water.add(l * B * 100)
    l += 1
for i in range(1,k):
    for j in range(1,l):
        if (i * A + j * B) * 100 <= F:
            water.add((i * A + j * B) * 100)
        else:
            break

water = list(water)
sugar = []
concentration = []
for i in range(len(water)):
    sugar_limit = min(water[i] // 100 * E, F - water[i])
    temp,k = 0,0
    while k * C <= sugar_limit:
        l = (sugar_limit - k * C) // D
        while l >= 0:
            if k * C + l * D > temp:
                temp = k * C + l * D
            l -= 1
        k += 1
    sugar.append(temp)
    concentration.append(sugar[i] / (water[i] + sugar[i]))

i = concentration.index(max(concentration))
print(water[i] + sugar[i],sugar[i])

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water, k, l = set(), 1, 1
while k * A * 100 <= F:
    water.add(k * A * 100)
    k += 1
while l * B * 100 <= F:
    water.add(l * B * 100)
    l += 1
for i in range(1, k):
    for j in range(1, l):
        if (i * A + j * B) * 100 <= F:
            water.add((i * A + j * B) * 100)
        else:
            break

water = list(water)
suger = []
concentration = []
for i in range(len(water)):
    suger_limit = min(water[i] // 100 * E, F - water[i])
    temp, k = 0, 0
    while k * C <= suger_limit:
        l = (suger_limit - k * C) // D
        while l >= 0:
            if k * C + l * D > temp:
                temp =  k * C + l * D 
            l -= 1
        k += 1
    suger.append(temp)
    concentration.append(suger[i] / (water[i] + suger[i]))

i = concentration.index(max(concentration))
print(water[i] + suger[i], suger[i])

Solution (Python):
A, B, C, D, E, F = map(int, input().split())

lst = []

for a in range(0, F, 100*A):
    for b in range(0, F, 100*B):
        x = a + b
        if x == 0 or x > F:
            continue
            
        for c in range(0, F, C):
            for d in range(0, F, D):
                y = c + d
                if x + y > F or 100*y/(x+y) > 100*E/(100+E):
                    break
                lst.append((100*y/(x+y), x+y, y))
                
print(max(lst)[1], max(lst)[2])

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
res = (100 * a, 0)
for aa in range(0, f + 1, 100 * a):
    for bb in range(0, f + 1, 100 * b):
        w = aa + bb
        if w == 0 or w >= f:
            continue
        r = f - w
        for cc in range(0, r + 1, c):
            for dd in range(0, r + 1, d):
                s = cc + dd
                t = w + s
                if t > f or 100 * s > e * w:
                    continue
                if s * res[0] > res[1] * t:
                    res = (t, s)
print(*res)

Solution (Python):
import sys
import math
from fractions import gcd





def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""


 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())


 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


A, B, C, D, E, F =  map(int, sys.stdin.readline().split())

def bluteforce(limit):
    suger = 0
    for c in range(limit // C + 1):
        for d in range(limit // D + 1):
            tmpsum = c * C + d * D
            if tmpsum > limit:
                break
            suger = max(suger,tmpsum)
    return suger

def greedy(limit):
    suger = 0

    while True:
        if limit >= D:
            limit -= D
            suger += D
            continue
        elif limit >= C:
            limit -= C
            suger += C
            continue
        else:
            return suger

a_m = 0
a_s = 0
dense = 0
for a in range(1, 31):
    for b in range(0, 31):
        water = (100 * a * A) + (100 * b * B)
        if water >= F:
            break
        wei_lim = F - water
        
        suger = bluteforce(min((a * A + b * B) * E, wei_lim))
        mass = water + suger
        d = (suger / mass) * 100
        if d >= dense:
            
            dense = d
            a_m = mass
            a_s = suger

print(a_m, a_s)

Solution (Python):
A,B,C,D,E,F = map(int, input().split())

val_max = 0
for a in range(0,1+F//(100*A)):
  for b in range(0,1+(F - 100*A*a)//(100*B)):
    if (a==0)&(b==0):
      continue
    for c in range(0,1+(F - 100*A*a - 100*B*b)//C):
      for d in range(0,1+(F - 100*A*a - 100*B*b - C*c)//D):
        if C*c+D*d <= E*(A*a+B*b):
          val = (C*c + D*d)/(100*A*a + 100*B*b + C*c + D*d)
          if val >= val_max:
            val_max = val
            ans1 = 100*A*a + 100*B*b + C*c + D*d
            ans2 = C*c + D*d
print(int(ans1),int(ans2))

Solution (Python):
aw,bw,cs,ds,ep,fm=map(int,input().split())

na=fm//(aw*100)
nb=fm//(bw*100)

ans=0
li=[]
for ia in range(na+1):
    for ib in range(nb+1):
        total_water=ia*aw*100+ib*bw*100       
        
        if total_water>fm:
            break
        if total_water==0:
            break
        
        if total_water in li:
            break
        li.append(total_water)
        
        for ic in range((((total_water//100)*ep)//cs)+1):
            for id in range((((total_water//100)*ep)//ds)+1):

                total=total_water+ic*cs+id*ds
                if total>fm:
                    break
                if (ic*cs+id*ds)/total>=ans and ic*cs+id*ds<=total_water//100*ep:
                    ans_total=total
                    ans_sugar=ic*cs+id*ds
                    ans=(ic*cs+id*ds)/total
print(ans_total,ans_sugar)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())

M = 0
S = 0
N = 30
ansp = 0
tmpM = 0
tmpS = 0
SUGAR = [0]*3001
SUGAR[0] = 1
for i in range(1,3001):
    if i - C >= 0:
        if SUGAR[i-C] == 1:
            SUGAR[i] = 1
    if i - D >= 0:
        if SUGAR[i-D] == 1:
            SUGAR[i] = 1

for i in range(31):
    for j in range(31-i):
        tmpM = 100*A*i+100*B*j
        maxS = E*(A*i+B*j)
        if tmpM != 0 and tmpM <= F:
            for k in range(E*(A*i+B*j)+1):
                l = E*(A*i+B*j) - k
                
                if SUGAR[l] == 1 and l+tmpM <= F:
                    tmpS = l
                    break
            if tmpS/(tmpM+tmpS) > ansp:
                ansp = tmpS/(tmpM+tmpS)
                M = tmpM
                S = tmpS
if M != 0:
    print(*[M+S,S])
else:
    print(*[100*A,0])

Solution (Python):
a, b, c, d, e, f = map(int, input().split())

limit = e / (100 + e)

mx = 0
ans = [100 * a, 0]

a_max = f // (100 * a)
for a_i in range(a_max + 1):
    ag = 100 * a * a_i
    bcdg_max = f - ag
    b_max = bcdg_max // (100 * b)
    for b_i in range(b_max + 1):
        bg = 100 * b * b_i
        if ag + bg == 0:
            continue
        cdg_max = bcdg_max - bg
        c_max = cdg_max // c
        for c_i in range(c_max + 1):
            cg = c * c_i
            dg_max = cdg_max - cg
            d_max = dg_max // d
            for d_i in range(d_max + 1):
                dg = d * d_i
                tmp = (cg + dg) / (ag + bg + cg + dg)
                if mx < tmp <= limit:
                    mx = tmp
                    ans = [ag + bg + cg + dg, cg + dg]

print(*ans)

Solution (Python):
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

A, B, C, D, E, F, = map(int, input().split())

A = A * 100
B = B * 100

ans = 0
m = (0, 0)
for i in range(int(F / A) + 1):
    for j in range(int(F / B) + 1):
        for k in range(80):
            for l in range(80):
                wa = (A * i) + (B * j)
                su = (C * k) + (D * l)

                if wa + su > F:
                    continue

                if (wa // 100 * E) < su:
                    continue

                if wa == 0:
                    continue

                t = (su * 100) / (wa + su)
                if ans <= t:
                    ans = t
                    m = (wa, su)

print(sum(m), m[1])

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c, d, e, f = list(map(int, input().rstrip('\n').split()))
    mn = 0
    x = y = 0
    for i in range(f // (a * 100) + 1):
        for j in range((f - 100 ** i) // (b * 100) + 1):
            for k in range((f - 100 * i - 100 * j) // c + 1):
                for l in range((f - 100 * i - 100 * j - k) // d + 1):
                    if 100 * i * a + 100 * j * b + c * k + d * l <= f:
                        if a * i + b * j != 0 and (c * k + d * l) / (a * i + b * j) <= e:
                            if mn < (c * k + d * l) / (100 * i * a + 100 * j * b + c * k + d * l):
                                if (100 * i * a + 100 * j * b + c * k + d * l) <= f:
                                    mn = (c * k + d * l) / (100 * i * a + 100 * j * b + c * k + d * l)
                                    x = 100 * i * a + 100 * j * b + c * k + d * l
                                    y = c * k + d * l
    if x == y == 0:
        print(a * 100, 0)
    else:
        print(x, y)



if __name__ == '__main__':
    slove()

Solution (Python):

import sys
from math import ceil, floor

def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    
    x = []
    y = []  

    for i in range(ceil(F/(100*A))+1):
        for j in range(ceil(F/(100*B))+1):
            dx = 100*A*i+100*B*j
            if(min(100*A,100*B) <= dx <= F):
                x.append(dx)

    for i in range(ceil(F/C)+1):
        for j in range(ceil(F/C)+1):
            dy = C*i+D*j
            if(0 <= dy <= F):
                y.append(dy)

    x = sorted(list(set(x)))
    y = sorted(list(set(y)))
    
    w = x[0]
    s = y[0]

    for i in x:
        for j in y:
            de = 100*s/(w+s)
            ne = 100*j/(i+j)
            if(i+j <= F and de < ne <= 100*E/(100+E)):
                
                w = i
                s = j

    print(w+s, s)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    D = int(next(tokens))  
    E = int(next(tokens))  
    F = int(next(tokens))  
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Solution (Python):
A,B,C,D,E,F = map(int, input().split())

W = []
S = []
for i in range((F//A)+1):
	j = 0
	while True:
		temp =  100*A*i + 100*B*j
		if temp <= F:
			W.append(temp)
		else:
			break

		j += 1


for i in range((F//C)+1):
	j = 0
	while True:
		temp =  C*i + D*j
		if temp <= F:
			S.append(temp)
		else:
			break

		j += 1

W.pop(0)
S.pop(0)

ans = 0
ans_whole = 0
ans_sugar = 0
for w in W:
	for s in S:
		if w+s <= F and s <= (w/100)*E:
			if ans <= (100*s)/(w+s):
				ans = (100*s)/(w+s)
				ans_whole = w+s
				ans_sugar = s

if ans == 0:
	print(100*A, end = " ")
	print(0)

else:
	print(ans_whole, end= " ")
	print(ans_sugar)

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
a=b=d=0
m=lambda:100*(A*a+B*b)+D*d
l=[]
while m()<=F:
 while m()<=F:
  while m()<=F:
   c=min((E*(A*a+B*b)-D*d)//C,(F-m())//C)
   if(a+b>0)&(c>=0):l+=[(m()+C*c,C*c+D*d,E-(C*c+D*d)/(A*a+B*b))]
   d+=1
  b+=1;d=0
 a+=1;b=0
l.sort(key=lambda x:x[2])
print(*l[0][:2])

Solution (Python):
import bisect

a,b,c,d,e,f = map(int, input().split())

water = set()
for i in range(31):
    for j in range(31):
        w = i*a + j*b
        if w <= f//100:
            water.add(w)
water = sorted(water)

suger = set()
for i in range(1501):
    j = 0
    while i*c + j*d <= 1500:
        suger.add(i*c+j*d)
        j += 1
suger = sorted(suger)

ans = []
for w in water:
    sid = bisect.bisect_right(suger, w*e) - 1
    while suger[sid] + w*100 > f and sid > 0:
        sid -= 1
    if w != 0:
        total = w*100 + suger[sid]
        ans.append([suger[sid]/total, total, suger[sid]])
ans.sort(key=lambda x:x[0])
print(ans[-1][1], ans[-1][2])