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())
W = set()
S = set()
wtr = 100*A
sgr = 0

i = 1
j = 0
while(wtr <= F):
  while(wtr <= F):
    W.add(wtr)
    wtr = i*A*100 + j*B*100
    j +=1
  i +=1
  j = 0
  wtr = i*A*100 + j*B*100
  
i = 0
j = 0
while(sgr <= F):
  while(sgr <= F):
    S.add(sgr)
    sgr = i*C + j*D
    j +=1
  i +=1
  j = 0
  sgr = i*C + j*D
answtr = 100*A
anssgr = 0
  
for wtr in W:
  for sgr in S:
    if (sgr*(answtr+anssgr) > anssgr*(wtr+sgr)) and (sgr*(100+E)<=E*(wtr+sgr) and (wtr+sgr<=F)):
      answtr = wtr
      anssgr = sgr
print("{} {}".format(answtr+anssgr, anssgr))

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
waters = set()
iM = F//(100*A) + (not not F%(100*A))
jM = F//(100*B) + (not not F%(100*B))
for i in range(iM):
    for j in range(jM):
        if i*A*100+j*B*100>F:
            continue
        else:
            waters.add((i*A*100+j*B*100,(i*A+j*B)*E))

waters = list(waters)
waters.sort()

maxW,maxS = A*100,0
sugars = [False]*3001
sugars[0] = True

for i in range(3001):
    if sugars[i]:
        if i+C <3001:
            sugars[i+C]=True
        if i+D <3001:
            sugars[i+D]=True 

for water,sugarM in waters:
    for i in range(sugarM,-1,-1):
        if i+water>F:
            continue
        if sugars[i]:
            maxSugar = i
            break

    if (maxSugar+water)*maxS<maxSugar*(maxW+maxS):
        maxW = water
        maxS = maxSugar
print(maxW+maxS,maxS)

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
ans = []
for ai in range(31):
    bb = (f - (ai * a * 100)) // b
    for bi in range(bb + 1):
        if ai == bi == 0:
            continue
        cc = (f - (ai * a * 100 + bi * b * 100)) // c
        for ci in range(cc + 1):
            dd = (f - (ai * a * 100 + bi * b * 100 + ci * c)) // d
            for di in range(dd + 1):
                if 100 * a * ai + 100 * b * bi + c * ci + d * di <= f:
                    if (c * ci + d * di)/(100 * a * ai + 100 * b * bi) <= e/100:
                        ans.append([(c * ci + d * di)/(100 * a * ai + 100 * b * bi + c * ci + d * di), 100 * a * ai + 100 * b * bi + c * ci + d * di, c * ci + d * di])
ans.sort(reverse=True)
print(ans[0][1], ans[0][2])

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
beaker = {'water':0, 'sugar':0, 'percent':0}
maxpercent=e/(100+e)
maxtimes = f // (100 + e)
maxc = e*maxtimes//c
percent = 0
for i in range(maxc + 1):
    for j in range((e*maxtimes-i*c)//d + 1):
        sugar = i*c + j*d
        minwater = sugar/maxpercent - sugar
        maxa = int((minwater + 100*a)//(100*a))
        maxb = int((minwater + 100*b)//(100*b))
        for atimes in range(maxa + 1):
            for btimes in range(maxb + 1):
                if 100 * (atimes * a + btimes * b)< minwater:
                    continue
                water = 100 * (atimes * a + btimes * b)
                if water + sugar == 0 or water + sugar > f:
                    continue
                percent = 100 * sugar/(water + sugar)
                if beaker['percent'] <= percent:
                    beaker['water']=water
                    beaker['sugar']=sugar
                    beaker['percent']=percent
print(str(beaker['water']+beaker['sugar']) + ' ' + str(beaker['sugar']))

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

from fractions import gcd

highest_concentration=-1

for a in range(F//(100*A) +1):
  for b in range((F-100*A*a)//(100*B) +1):
    water = 100*A*a + 100*B*b
    if not water:
      continue
      
    max_sugar = min(E*(A*a+B*b), F-water)
    
    for c in range(min(D,(max_sugar//C)+1)):
      d = (max_sugar -c*C)//D
      sugar = c*C + d*D
      if sugar/(water+sugar) > highest_concentration:
        highest_concentration = sugar/(water+sugar)
        
        
        answer = (water+sugar, sugar)
        
print(*answer)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
water=[]
salt=[]
for i in range(30):
  for j in range(30):
    x=a*100*i+b*100*j
    if x<=f:
      water.append(x)
for i in range(1501):
  for j in range(1501):
    x=c*i+d*j
    if x<=f:
      salt.append(x)
water=list(set(water))
salt=list(set(salt))
stack=0
ans_sol=min(a*100,b*100)
ans_sal=0
for i in water:
  for j in salt:
    if 1<=i+j<=f and j*100<=i*e:
      if j/(i+j)>stack:
        stack=j/(i+j)
        ans_sol=i+j
        ans_sal=j
print(ans_sol,ans_sal)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
flag=True
for i in range(1,f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1:
      if 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
        dp[i]=max(dp[i],dp[i-j]+j)
      else:
        for k in [a*100,b*100]:
          if i-k-j>=0 and dp[i-k-j]!=-1:
            if 100*(dp[i-k-j]+j)<=e*(i-(dp[i-k-j]+j)):
              dp[i]=max(dp[i],dp[i-k-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<(dp[i]*100)/i:
      stack=(dp[i]*100)/i
      index=i
print(index,dp[index])

Solution (Python):
a,b,c,d,e,f = map(int,input().split())
ans = [0,0,0]
for i in range(0,3000//(a*100)+1):
    for j in range(0,3000//(b*100)+1):
        g = i*a*100+j*b*100
        if i==j==0 or g>f:
            continue
        for k in range(0,(f-g)//c+1):
            for l in range(0,(f-g)//d+1):
                if g+k*c+l*d>f:
                    continue
                if ans[2]<=(k*c+l*d)/(g+k*c+l*d) and k*c+l*d<=e*g/100:
                    ans[0] = g+k*c+l*d
                    ans[1] = k*c+l*d
                    ans[2] = (k*c+l*d)/(g+k*c+l*d)
print(ans[0],ans[1])

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

W = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1-i,100*B):
        W.add(i+j)
        
S = set()
for i in range(0,F+1,C):
    for j in range(0,F+1-i,D):
        S.add(i+j)

rate = 0
for w in W:
    for s in S:
        if 0 < w+s <= F and s/(w+s) <= E/(E+100):
            if s/(w+s) >= rate:
                rate= s/(w+s)
                res1,res2 = w+s,s
                
print(res1,res2)

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
A*=100
B*=100
ans=(A,0)
Max=0
for a in range(1+F//A):
    F_a=F-a*A
    water_a=a*A
    for b in range(1+F_a//B):
        F_b=F_a-b*B
        water_b=water_a+b*B
        for c in range(1+F_b//C):
            suger_c=c*C
            if suger_c>E*water_b/100:break
            F_c=F_b-c*C
            d=min(F_c//D,(E*water_b//100-suger_c)//D)
            suger_d=suger_c+d*D
            if water_b+suger_d==0:continue
            if suger_d/(water_b+suger_d)>Max:
                Max=suger_d/(water_b+suger_d)
                ans=(water_b+suger_d,suger_d)
print(str(int(ans[0]))+' '+str(int(ans[1])))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
conc = 0
answater = 100*A
anssugar = 0


for i in range(1, F//(100*A)+1):
    for j in range(F//(100*A)+1):
        if 100*A*i+100*B*j>F:
            break
        for k in range(E*(A*i+B*j)+1):
            if 100*A*i+100*B*j+C*k>F or C*k>E*(A*i+B*j):
                    break
            for l in range(E*(A*i+B*j)+1):
                if 100*A*i+100*B*j+C*k+D*l>F or C*k+D*l>E*(A*i+B*j):
                    break
                tmp = 100*(C*k+D*l)/(100*A*i+100*B*j+C*k+D*l)
                if tmp > conc:
                    conc = tmp
                    answater = 100*A*i+100*B*j+C*k+D*l
                    anssugar = C*k+D*l

print(answater, anssugar)

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

max_sw = 100 * a
max_s = 0
x = f // (a * 100)
y = f // (b * 100)
for i in range(x + 1):
    for j in range(y + 1):
        if i == 0 and j == 0:
            continue
        water = i * a * 100 + j * b * 100
        if water <= f:
            z = e * water // 100 // c
            w = e * water // 100 // d
            for k in range(z + 1):
                for l in range(w + 1):
                    sugar = k * c + l * d
                    if sugar + water <= f and e * water // 100 >= sugar \
                            and water + sugar > 0:
                        density = sugar / (sugar + water)
                        if density >= max_s / max_sw:
                            max_s = int(sugar)
                            max_sw = int(sugar + water)


print("{} {}".format(max_sw, max_s))

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

water = 0
sugar = 0
rate = 0

for x in range(31):
    for y in range(31):
        if x + y == 0:
            continue
        for z in range(101):
            for w in range(101):
                now_water = 100*a*x + 100*b*y + c*z + d*w
                if now_water > f:
                    break
                now_sugar = c*z + d*w
                if now_water*e >= now_sugar*(100 + e):
                    now_rate = now_sugar/now_water
                    if rate <= now_rate:
                        rate = now_rate
                        water = now_water
                        sugar = now_sugar


print(water,sugar)

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

ans = 0
ansa = 0
ansb = 0


for a in range(0,(F//(100*A))+1):
    
    for b in range(0,((F-100*a*A)//(100*B))+1):
        
        
        for pa in range((E*(a*A+b*B)//C) + 1):
            
            limsug = F-100*(a*A+b*B)-pa*C
            if limsug>0:
                for ja in range((limsug//D)+1):

                    if a+b+pa+ja != 0:
                        nodo = 100*(pa*C+ja*D)/(100*(a*A+b*B)+pa*C+ja*D)
                        

                        
                        if nodo <= E and ans <= nodo and E*(a*A+b*B)>=pa*C+ja*D:
                            ans = nodo
                            ansa = 100*(a*A+b*B)+pa*C+ja*D
                            ansb = pa*C+ja*D


print(ansa,ansb)

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

ans = {}


def main():
    MAX_A = F // (100 * A)

    for i in range(MAX_A + 1):
        MAX_B = (F - i * 100 * A) // (100 * B)

        for j in range(MAX_B + 1):
            if i == 0 and j == 0:
                continue

            a = i * A + j * B

            SAT = a * E

            CD = F - a * 100

            SAT_FLG = True

            if CD < SAT:
                SAT_FLG = False

            CD = min(SAT, CD)

            MAX_C = CD // C

            for k in range(MAX_C + 1):
                l = (CD - k * C) // D

                b = k * C + l * D

                if SAT == b:
                    print(a * 100 + b, b)
                    return

                LACK = SAT - b
                if not LACK in ans:
                    
                    ans[LACK] = (a * 100 + b, b, SAT_FLG)
                elif not ans[LACK][-1]:
                    
                    
                    ans[LACK] = (a * 100 + b, b, SAT_FLG)

    print(" ".join([str(i) for i in ans[min(ans.keys())][:-1]]))
    return


main()

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    A = list(map(int, input().split()))

    wat1 = A[0] * 100
    wat2 = A[1] * 100
    sug1 = A[2]
    sug2 = A[3]
    max_conc = A[4]
    max_volume = A[5]
    max_suger = max_conc * max_volume // 100

    W = set()
    for i in range(31):
        for j in range(31):
            w = wat1 * i + wat2 * j
            if w <= max_volume:
                W.add(w)

    S = set()
    for i in range(max_suger):
        for j in range(max_suger):
            s = sug1 * i + sug2 * j
            if s <= max_volume:
                S.add(s)

    vol = 0
    suger = 0
    conc = 0
    for w in W:
        if w == 0:
            continue
        for s in S:
            cur_conc = s / (w / 100)
            if cur_conc > max_conc:
                continue

            cur_conc = 100 * s / (w + s)
            if cur_conc >= conc and w+s <= max_volume:
                conc = cur_conc
                vol = w + s
                suger = s

    print(vol, suger)


if __name__ == '__main__':
    main()

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
mizu = 0
satou = 0
noudo = 0
for i in range(0,F//(100*A)+1):
  for j in range(0,F//(100*B)+1):
    curmizu = (A*i+B*j)*100
    for k in range(0,(curmizu*E//(100*C))+1):
      for l in range(0,(curmizu*E//(100*D))+1):
        cursatou = k*C+l*D
        if curmizu+cursatou <= F:
          if cursatou <= curmizu*E/100:
            if curmizu+cursatou != 0:
              if 100*(cursatou)/(curmizu+cursatou) >= noudo:
                mizu = curmizu
                satou = cursatou
                noudo = 100*(cursatou)/(curmizu+cursatou)
print(mizu+satou,satou)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
ans = []
def my_max(x,y):
    if x[0] < y[0]:
        return y
    else:
        return x
maxi = [0,0,0]
for a in range(F // (A*100) + 1):
    for b in range(F // (B*100) + 1):
        water =  100*a*A + 100*b*B 
        if water <= F:
            for c in range(E*water//100//C+1):
                for d in range(E*water//100//D+1):
                    suger = C*c + D*d
                    if suger+water <= F and E*water//100 >= suger \
                    and water + suger > 0:
                        t = (suger/(suger+water),suger+water,suger)
                        maxi = my_max(t,maxi)
ans.sort()
print(maxi[1],maxi[2])

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
ans = []
def my_max(x,y):
    if x[0] < y[0]:
        return y
    else:
        return x
maxi = [0,0,0]
for a in range(F // (A*100) + 1):
    for b in range(F // (B*100) + 1):
        water =  100*a*A + 100*b*B 
        if water <= F:
            for c in range(E*water//100//C+1):
                for d in range(E*water//100//D+1):
                    suger = C*c + D*d
                    if suger+water <= F and E*water//100 >= suger \
                    and water + suger > 0:
                        t = (suger/(suger+water),suger+water,suger)
                        maxi = my_max(t,maxi)
ans.sort()
print(maxi[1],maxi[2])

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
ans = []
for a in range(F // (A*100) + 1):
    for b in range(F // (B*100) + 1):
        water =  100*a*A + 100*b*B 
        if water <= F:
            for c in range(E*water//100//C+1):
                for d in range(E*water//100//D+1):
                    suger = C*c + D*d
                    if suger+water <= F and E*water//100 >= suger:
                        try:
                            n = suger / (suger+water)
                            ans.append([n,suger+water,suger])
                        except:
                            pass
ans.sort()
print(ans[-1][1],ans[-1][2])

Solution (Python):
def sugar_water(A: int, B: int, C: int, D: int, E: int, F: int)->tuple:
    max_dens = 0
    min_a, min_b, min_c, min_d = 0, 0, 0, 0
    for a in range(F//(100*A) + 1):
        for b in range((F-100*A*a)//(100*B) + 1):
            for c in range((F-100*A*a-100*B*b)//C + 1):
                for d in range((F-100*A*a-100*B*b-c*C)//D + 1):
                    if F < 100*A*a + 100*B*b + c + d:
                        continue
                    if E * (100*a*A + 100*b*B) < (c*C + d*D) * 100:
                        continue
                    if a == 0 and b == 0 and c == 0 and d == 0:
                        continue

                    dens = (c*C + d*D) / (100*a*A + 100*b*B + c*C + d*D)

                    if max_dens < dens:
                        min_a, min_b, min_c, min_d = a, b, c, d
                        max_dens = dens
    if min_a == 0 and min_b == 0 and min_c == 0 and min_d == 0:
        min_a = 1
    return 100*A*min_a + 100*B*min_b + C*min_c + D*min_d, C*min_c + D*min_d


if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split())
    w, s = sugar_water(A, B, C, D, E, F)
    print(w, s)

Solution (Python):

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

    x_list = []
    for i in range(F+1):
        for j in range(F+1):
            x = 100*A*i + 100*B*j
            if x <= F:
                x_list.append(x)

    y_list = []
    for i in range(F+1):
        for j in range(F+1):
            y = i*C + j*D
            if y <= F:
                y_list.append(y)

    res = 0
    res_x = 0
    res_y = 0

    x_list = list(set(x_list))
    y_list = list(set(y_list))

    for x in x_list:
        for y in y_list:
            if x + y > F:
                continue

            if y == 0:
                tmp = 0
            else:
                tmp = y/(x+y)

            if tmp > E/(100+E):
                continue

            if res <= tmp:
                res = tmp
                res_x = x
                res_y = y


    print(res_x+res_y,res_y)

if __name__ == "__main__":
    main()

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
water = []
for i in range(int(f/100)+1):
    for j in range(int(f/100)+1):
        if 0 < a*i*100 + b*j*100 <= f:
            water.append(a*i*100 + b*j*100)
water.sort()
sugar = []
for i in range(int(f/c)+1):
    for j in range(int(f/d)+1):
        if c*i+(c*i)*e/100 + d*j+(d*j)*e/100 <= f:
            sugar.append(c*i + d*j)
sugar.sort(reverse=True)
check = -1.0
for w in list(set(water)):
    for s in list(set(sugar)):
        if w+s <= f and s <= w*e/100:
            if check < 100*s/(w+s):
                check = 100*s/(w+s)
                ans1, ans2 = w+s, s
print(ans1, ans2)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
waters = set()
sugars = set()
for i in range(F//(A*100)+1):
    for j in range(F//(B*100)+1):
        if i!=0 or j!=0:
            if A*i*100 +B*j*100 <= F:
                waters.add(100*A*i+100*B*j)
for i in range(F//(C)+1):
    for j in range(F//(D)+1):
        if C*i +D*j <= F:
            sugars.add(C*i+D*j)

max_ratio = 0
for water in waters:
    for sugar in sugars:
        ratio =  sugar/(water+sugar)
        if water+sugar<=F and sugar<=E*(water//100):
            if ratio >= max_ratio:
                ans = (water+sugar, sugar)
                max_ratio = ratio
print(*ans)

Solution (Python):


"""
Created on 2019/3/23
Solved on 2019/3/
@author: shinjisu
"""




def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m) for i in range(n)] 
class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    global E, F
    db = Debug()
    db.off()
    A, B, C, D, E, F = getIntList()
    db.dmp((A, B, C, D, E, F), 'A, B, C, D, E, F')
    a = F // (100 * A)
    b = F // (100 * B)
    c = F // C
    d = F // D
    db.dmp((a, b, c, d), 'a, b, c, d')
    maxConc, maxWater, maxSugar = -1.0, 0, 0
    for i in range(a+1):
        for j in range(b+1):
            water = A*i + B*j
            if water == 0:
                continue
            if water*100 >= F:  
                break
            for n in range(c+1):
                for m in range(d+1):
                    sugar = C*n + D*m
                    conc = sugar / (sugar+water*100) * 100
                    
                    if sugar/water > E:  
                        
                        break
                    if water*100+sugar > F:  
                        
                        break
                    if conc > maxConc:
                        
                        maxConc, maxWater, maxSugar = conc, water, sugar

    db.dmp((maxConc, maxWater, maxSugar),'max conc, water, sugar')
    return maxWater*100+maxSugar, maxSugar


ans = prob()
for elm in ans:
    print(elm, end=' ')

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100
water = set()
sugar = set()
for i in range(f//a + 1):
    for j in range((f - a*i)//b + 1):
        water.add(a*i + b*j)
ms = max(water) // 100 * e
for i in range(ms//c + 1):
    for j in range((ms - c*i)//d + 1):
        sugar.add(c*i + d*j)
def maxcon(x, y, z, w):
    if (z + w)*y >= (x + y)*w:
        return x, y
    else:
        return z, w
maxconwater = 100
maxconsugar = -1
for w in water:
    for s in sugar:
        if w // 100 * e >= s and w + s <= f:
            maxconwater, maxconsugar = maxcon(maxconwater, maxconsugar, w, s)
print(maxconwater + maxconsugar, maxconsugar)

Solution (Python):
w1, w2, s1, s2, s_max, b_max = map(int, input().split())
waters = [0]
waters_base = [0]
while len(waters_base) > 0:
    base = waters_base.pop()
    water1 = base + 100 * w1
    water2 = base + 100 * w2
    if water1 not in waters and water1 <= b_max:
        waters.append(water1)
        waters_base.append(water1)
    if water2 not in waters and water2 <= b_max:
        waters.append(water2)
        waters_base.append(water2)
waters.pop(0)
sugars = [0]
sugars_base = [0]
while len(sugars_base) > 0:
    base = sugars_base.pop()
    sugar1 = base + s1
    sugar2 = base + s2
    if sugar1 not in sugars and sugar1 <= b_max:
        sugars.append(sugar1)
        sugars_base.append(sugar1)
    if sugar2 not in sugars and sugar2 <= b_max:
        sugars.append(sugar2)
        sugars_base.append(sugar2)
max_radio = -1
result = (-1, -1)
for water in waters:
    for sugar in sugars:
        if b_max < water + sugar:
            continue
        if water // 100 * s_max < sugar:
            continue
        ratio = sugar / (water + sugar)
        if max_radio < ratio:
            max_radio = ratio
            result = (water + sugar, sugar)
print(*result)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
concent = 0
ans = []
for one in range(F//(100*A)+1):
    for two in range((F-100*A*one)//(100*B)+1):
        for three in range((F-100*A*one-100*B*two)//C+1):
            for four in range((F-100*A*one-100*B*two-C*three)//D+1):
                water = 100*A*one+100*B*two
                sugar = C*three+D*four
                all = water + sugar
                if all == 0:
                    continue
                if E*water//100 < sugar or all > F:
                    continue
                if concent < 100*sugar/all:
                    concent = 100*sugar/all
                    ans = [all,sugar]
if len(ans) == 0:
    print(str(100*A)+' '+str(0))
else:
    print(str(ans[0])+' '+str(ans[1]))

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
concent = 0
ans = []
for one in range(F//(100*A)+1):
    for two in range((F-100*A*one)//(100*B)+1):
        for three in range((F-100*A*one-100*B*two)//C+1):
            for four in range((F-100*A*one-100*B*two-C*three)//D+1):
                water = 100*A*one+100*B*two
                sugar = C*three+D*four
                all = water + sugar
                if all == 0:
                    continue
                if E*water//100 < sugar or all > F:
                    continue
                if concent < 100*sugar/all:
                    concent = 100*sugar/all
                    ans = [all,sugar]
if len(ans) == 0:
    print(str(100*A)+' '+str(0))
else:
    print(str(ans[0])+' '+str(ans[1]))

Solution (Python):
import math
import bisect
A,B,C,D,E,F = map(int, input().split())
x = [A * a + B * b for b in range(31) for a in range(31)]
y = [C * c + D * d for d in range(1501) for c in range(1501)]
x.remove(0)
x = list(set(x))
y = list(set(y))
x.sort()
y.sort()
x = x[:bisect.bisect_right(x,F//100+1)]
y = y[:bisect.bisect_left(y,F)]


water = A
suger = 0
for i in x:
    for j in y:
        if j <= i * E and i * 100 + j <= F:
            if j / (i * 100 + j) > suger / (water * 100 + suger):
                water = i
                suger = j
print("{} {}".format(water * 100 + suger, suger))

Solution (Python):
import math
A,B,C,D,E,F = map(int, input().split())
water = A
suger = 0
for a in range(31):
    for b in range(31):
        subwater = A * a + B * b
        if subwater == 0:
                continue
        for c in range(1501):
            subsuger = C * c
            if subsuger <= subwater * E:
                if F - subwater * 100 - subsuger > 0:
                    subsuger += D * min((F - subwater * 100 - subsuger) // D, (subwater * E - subsuger) // D)
                if subsuger <= subwater * E and subwater * 100 + subsuger <= F and subsuger / (subwater * 100 + subsuger) > suger / (water * 100 + suger):
                    water = subwater
                    suger = subsuger
print("{} {}".format(water * 100 + suger, suger))

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

used = [[-1 for i in range(3000)] for j in range(3000)]
def dfs(w,s,wa,sa):
   
    if w+s > f or e*w/100 < s:
        w -= wa
        s -= sa
        if w==0:
            return [0,0,s]
        else:
            return [100*s/(w+s), w, s]

    if used[w][s] == 1:
        return [0,0,0]
    d1 = dfs(w+100*a,s,100*a,0)
    d2 = dfs(w+100*b,s,100*b,0)
    d3 = dfs(w,s+c,0,c)
    d4 = dfs(w,s+d,0,d)
    
    dl = [d1,d2,d3,d4]
    max_n = max([d1[0], d2[0], d3[0], d4[0]])
    for x in dl:
        if x[0] == max_n:
            used[w][s] = 1
            return x

res = dfs(0,0,0,0)

print("{} {}".format(res[1]+res[2], res[2]))

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
max=0
ans=[0,0]

wlist=[]
for ia in range((f//100*a)+1):
  for ib in range(((f-ia)//100*b)+1):
    if 100*a*ia+100*b*ib<=f and 100*a*ia+100*b*ib not in wlist:
      wlist.append(100*a*ia+100*b*ib)
wlist.sort()
wlist.remove(0)

if c==1 or d==1:
  slist=[j for j in range(f+1)]
else:
  slist=set()
  for ic in range((f//c)+1):
    for id in range(((f-ic)//d)+1):
      if c*ic+d*id<=f:
        slist.add(c*ic+d*id)
  slist=list(slist)
slist.sort()

for w in wlist:
  for s in slist:
    if w+s>f or e/100<s/w:
      break
    if max<=100*s/(w+s):
      max=100*s/(w+s)
      ans=[w+s,s]
print(ans[0],ans[1])

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

ws = []
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		x = a + b
		if x <= F:
			ws.append(x)
			
ss = []
for c in range(0,F+1,C):
	for d in range(0,F-c+1,D):
		y = c + d
		if y <= F:
			ss.append(y)
				
ans = [0,100*A,0]
for w in ws:
	for s in ss:
		ws = w+s
		
		if not ws <= F:
			continue
		
		if ws == 0:
			continue
		
		e = s/ws*100
				
		if not e <= E/(100+E)*100:
			continue
		
		if ans[0] < e:
			ans = [e,ws,s]
				
print(ans[1],ans[2])

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

ws = []
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		x = a + b
		if x <= F:
			ws.append(x)
			
ss = []
for c in range(0,F+1,C):
	for d in range(0,F-c+1,D):
		y = c + d
		if y <= F:
			ss.append(y)
				
wss = []
for w in ws:
	for s in ss:
		ws = w+s
		
		if not ws <= F:
			continue
		
		if ws == 0:
			continue
		
		e = s/ws*100
				
		if not e <= E/(100+E)*100:
			continue
				
		wss.append([e,ws,s])
				
l = (sorted(wss,reverse=True,key=lambda x:x[0]))[0]
print(l[1],l[2])

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

maxE = 0
maxWS = [100*A,0]
for a in range(0,F//(100*A)+1):
	for b in range(0,(F-100*A*a)//(100*B)+1):
		if a +b == 0:
			continue
		for c in range(0,(F-100*A*a-100*B*b)//C+1):
			for d in range(0,(F-100*A*a-100*B*b-C*c)//D+1):
				
				s = C*c+D*d
				ws = 100*A*a+100*B*b+C*c+D*d
				e = s/ws*100
				
				if not e <= E/(100+E)*100:
					continue
				
				if maxE < e:
					maxE = e
					maxWS = [ws,s]
				
print(maxWS[0],maxWS[1])

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

maxE = 0
maxWS = [100*A,0]
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		if a +b == 0:
			continue
		for c in range(0,F-a-b+1,C):
			for d in range(0,F-a-b-c+1,D):
				
				e = (c+d)/(a+b+c+d)
				
				if not (c+d)/(a+b) <= E/100:
					continue
				
				if maxE < e:
					maxE = e
					maxWS = [a+b+c+d,c+d]
				
print(maxWS[0],maxWS[1])

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007






a,b,c,d,e,f = LI()
a *= 100
b *= 100
ans = [a,0]
for i in range(f//a+1):
    for j in range((f-a*i)//b+1):
        for k in range((f-a*i-b*j)//c+1):
            for l in range((f-a*i-b*j-c*k)//d+1):
                if i or j or k or l:
                    s = c*k+d*l
                    w = a*i+b*j
                    q = w*e//100
                    if s <= q:
                        if w+s <= f:
                            if ans[1]/ans[0] < s/(s+w):
                                ans = [w+s,s]
print(*ans)