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):
import bisect as bi
a,b,c,d,e,f = map(int,input().split())

liw = [0]*31
liw[0] = 1
for i in range(30):
  if liw[i] == 1:
    if i+a <= 30:
      liw[i+a] = 1
    if i+b <= 30:
      liw[i+b] = 1

liww = []
for i in range(1,31):
  if liw[i] == 1:
    liww.append(i)

maxs = 30*e+1
lis = [0]*maxs
lis[0] = 1
for i in range(maxs-1):
  if lis[i] == 1:
    if i+c <= maxs-1:
      lis[i+c] = 1
    if i+d <= maxs-1:
      lis[i+d] = 1
liss = []
for i in range(1,maxs):
  if lis[i] == 1:
    liss.append(i)

ans = [0,0,0]

for i in liww:
  if 100*i > f:
    break
  maxsug = min(f-100*i,i*e)
  
  if bi.bisect_right(liss,maxsug) == 0:
    tmpsug = 0
  else:
    
    tmpsug = liss[bi.bisect_right(liss,maxsug)-1]
  
  if ans[2] <= tmpsug/(tmpsug+100*i):
    ans[0] = tmpsug+100*i
    ans[1] = tmpsug
    ans[2] = tmpsug/(tmpsug+100*i)
print("{} {}".format(ans[0],ans[1]))

Solution (Python):
import sys
sys.setrecursionlimit(1000000)
a,b,c,d,e,f=map(int,input().split())
L=[]
M=[]
from functools import lru_cache
@lru_cache(maxsize=1000)
def dfs(s,w):
    if s+w>f or s>f*e/(100+e):
        return
    x=(100*s)/(s+w)
    m=(100*e)/(e+100)
    if x==m:
        L.append([x,s+w,s])
        return
    elif x>m:
        dfs(s,w+100*a)
        dfs(s,w+100*b)
    else:
        L.append([x,s+w,s])
        dfs(s+c,w)
        dfs(s+d,w)
dfs(0,100*a)
dfs(0,100*b)
LS=sorted(L,key=lambda x:x[0],reverse=True)
print(LS[0][1],LS[0][2])

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

W=[]
for i in range(30):
  for j in range(30):
    if (i*A+j*B)*100<=F:
      W.append((i*A+j*B)*100)
W=sorted(set(W))

S=[]
for i in range(F):
  for j in range(F):
    if i*C+j*D<=F:
      S.append(i*C+j*D)
S=sorted(set(S))

nou=0
for w in W:
  for s in S:
    if w+s<=F:
      if E*w//100>=s:
        if w!=0 or s!=0:
          if nou<=s/(w+s):
            nou=s/(w+s)
            ans=[w+s,s]
        
print(ans[0],ans[1])

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
W = []
for i in range(F + 1):
  for j in range(F + 1):
    if A * i * 100 + B * j * 100 < F:
      W.append(A * i * 100 + B * j * 100)
    else:
      break

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



      
ans = 0
ans1, ans2 = 0, 0
for i in S:
  for j in W:
    if i + j > 0 and i + j <= F and j * E >= 100 * i:
      if i / (i + j) >= ans:
        ans1, ans2 = i, j
        ans = i / (i + j)

print(ans1 + ans2, ans1)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
X = [1] + [0] * F
Y = [1] + [0] * F
for i in range(1, F+1):
    if i >= A*100 and X[i-A*100]: X[i] = 1
    if i >= B*100 and X[i-B*100]: X[i] = 1
    if i >= C and Y[i-C]: Y[i] = 1
    if i >= D and Y[i-D]: Y[i] = 1

ans = (0, 0)
ratio = -1
for i in range(100, F+1, 100):
    for j in range(F+1):
        if X[i] and Y[j]:
            if j <= i // 100 * E and i + j <= F:
                if j / i > ratio:
                    ans = (i+j, j)
                    ratio = j / i
print(*ans)

Solution (Python):
def examC():
    A, B, C, D, E, F = LI()
    water =set()
    for i in range(30):
        for j in range(30):
            if 100 * (i*A+j*B) > F or (i==0 and j==0):
                continue
            water.add(100 * (A*i+B*j))
    sugar = set()
    for i in water:
        j = 0
        while(True):
            if (j * C) * 100 > i * E or i+(j*C)>F:
                break
            k = 0
            while(True):
                if (j*C+k*D)*100>i*E or i+(j*C+k*D)>F:
                    j +=1
                    break
                sugar.add((i+j*C+k*D,j*C+k*D))
                k +=1
    ans = [0,0]; cur = float(-1)
    for i in sugar:
        if cur<i[1]/i[0]:
            ans = [i[0],i[1]]
            cur = i[1]/i[0]
    print(" ".join(map(str,ans)))



import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Solution (Python):
def examC():
    A, B, C, D, E, F = LI()
    water =set()
    for i in range(30):
        for j in range(30):
            if 100 * (i*A+j*B) > F or (i==0 and j==0):
                continue
            water.add(100 * (A*i+B*j))
    sugar = set()
    for i in water:
        j = 0
        while(True):
            if (j * C) * 100 > i * E or i+(j*C)>F:
                break
            k = 0
            while(True):
                if (j*C+k*D)*100>i*E or i+(j*C+k*D)>F:
                    j +=1
                    break
                sugar.add((i+j*C+k*D,j*C+k*D))
                k +=1
    ans = [0,0]; cur = float(-1)
    for i in sugar:
        if cur<i[1]/i[0]:
            ans = [i[0],i[1]]
            cur = i[1]/i[0]
    print(" ".join(map(str,ans)))



import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

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

sugar = []
water = []

for i in range(31):
    for j in range(31):
        x = 100*A*i+100*B*j
        if x != 0 and x <= F:
            water.append(x)
        
n = int(F/(100+E)*E)

for k in range(n):
    for l in range(n):
        y = C*k+D*l
        if y != 0:    
            sugar.append(y)

ans_water_sugar = 100*A
ans_sugar = 0
conce = 0 

for s in list(set(sugar)):
    for w in water:
        if w+s <= F:
            if s/w <= E/100:
                if conce < s/w:
                    conce = s/w
                    ans_water_sugar = s+w
                    ans_sugar = s

print(ans_water_sugar, ans_sugar)

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

L = []
for i in range(f//a//100+1):
    for j in range(f//b//100+1):
        if 0 < 100*(a*i+b*j) < f and 100*(a*i+b*j) not in L:
            L.append(100*(a*i+b*j))
            
W = 1
S = 0
for w in L:
    s = 0
    for j in range(w//c+1):
        for k in range(w//d+1):
            if (c*j+d*k)*100 <= e*w and c*j+d*k+w <= f:
                s = max(s, c*j+d*k)
    if S*(w+s) < s*(W+S):
        S = s
        W = w
    
if W >= 100:
    print(S+W, S)
else:
    print(100*a, 0)

Solution (Python):
A, B, C, D, E, F = [int(_) for _ in input().split()]

X = []
Y = []
for i in range(F):
    for j in range(F):
        x = A * i + B * j
        if x * 100 <= F:
            X.append(x)
        y = C * i + D * j
        if y <= F:
            Y.append(y)
m = -1
ans = []
for x in X:
    if x == 0: continue
    for y in Y:
        if x * 100 + y <= F and x * E >= y:
            if m < y / (x + y):
                m = y / (x + y)
                ans = (x * 100 + y, y)

print(*ans)

Solution (Python):
import math
a, b, c, d, e, f = [int(x) for x in input().split()]
threshold = e / (100 + e) * 100
max_concent = 0
max_total = 0
max_suger = 0
max_suger_try = int(threshold/100*f//c)
for i in range(31):
    for j in range(31):
        for k in range(max_suger_try):
            for l in range(max_suger_try):
                water = a * i * 100 + b * j * 100
                suger = c * k + d * l   
                if water == 0:
                    break
                concentration = suger / (water + suger) * 100
                if (water + suger > f or concentration > threshold) :
                    break
                else:
                    if concentration > max_concent:
                        max_concent = concentration
                        max_total = water + suger
                        max_suger = suger
if max_total == 0:
    max_total = a * 100
print("{} {}".format(max_total, max_suger))

Solution (Python):
num = list(map(int, input().split()))

A = num[0]
B = num[1]
C = num[2]
D = num[3]
E = num[4]
F = num[5]

watA_max = F // (100 * A)
sugar = 0
water = 0
beaker = F
ans = []
for i in range(1, watA_max+1):
    water = 100 * A * i
    beaker = F - (100 * A * i)
    watB_max = beaker // (100 * B)
    for j in range(watB_max+1):
        water = 100 * (A * i + B * j)
        beaker = F - (100 * (A * i + B * j))
        sugC_max = beaker // C
        for k in range(sugC_max+1):
            sugar = C * k
            beaker = F - (100 * (A * i + B * j)) - C * k
            if sugar * 100 > water * E:
                break
            sugD_max = beaker // D
            for l in range(sugD_max+1):
                sugar = C * k + D * l
                beaker = F - (100 * (A * i + B * j)) - C * k - D * l
                if sugar * 100 > water * E:
                    break
                if ans == [] or sugar / water >= ans[-1][-1]:
                    ans.append([sugar + water, sugar, sugar / water])
                
print(ans[-1][0], ans[-1][1])

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
w=set([])
for i in range(31):
    for j in range(31):
        x=a*i*100+b*j*100
        if 0<x<=f:
            w.add(x)
s=set([])
for i in range(3001):
    for j in range(3001):
        y=c*i+d*j
        if y<=f:
            s.add(y)
tmpn=-1
ans=[0,0]
for i in w:
    for j in s:
        if i+j<=f and i//100*e>=j:
            if tmpn<j/(1.0*(i+j)):
                tmpn=j/(1.0*(i+j))
                ans=[i+j,j]
print(*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())
ansx,ansy = 1, 0
for ai in range(F//(100*A)+1):
  for bi in range(F//(100*B)+1):
    if ai ==0 and bi ==0: continue
    s = 0
    for ci in range((F-ai*100*A + bi*100*B)//C +1):
      for di in range((F-ai*100*A + bi*100*B)//D +1):
        s = ci*C + di*D
        if s <=(ai*A + bi*B)*E and s + ai*100*A + bi*100*B <= F:
          if 100*ansy/(ansx+ansy) <= 100*s/(s + ai*100*A + bi*100*B):
            ansx = ai*100*A + bi*100*B
            ansy = s
      
print(ansx+ansy, ansy)

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
X=F//100
w,s=100*A,0
for x in range(X,0,-1):
    a,b=0,0
    while A*a<=x:
        b=(x-A*a)%B
        if b==0:
            break
        a+=1
    if b==0:
        b=(x-A*a)//B
        maxs=min(E*x,F-100*(A*a+B*b))
        c,d=0,0
        cc=0
        while C*cc<=maxs:
            dd=(maxs-C*cc)//D
            if C*cc+D*dd>C*c+D*d:
                c,d=cc,dd
            cc+=1
        if s/w<(C*c+D*d)/(100*(A*a+B*b)+C*c+D*d):
            s,w=C*c+D*d,100*(A*a+B*b)+C*c+D*d
print(w,s)

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

dp = [[False for i in range(3001)] for j in range(2)]
for i in range(3001):
    if i % C == 0:
        dp[0][i] = True
for i in range(3001):
    if i % D == 0 or dp[0][i] or (i - D >= 0 and dp[1][i - D]):
        dp[1][i] = True
    
ans_sugar = 0
ans_total = 0
for i in range(31):
    for j in range(31):
        water = i * 100 * A + j * 100 * B
        if water > F:
            break
        for k in range(3000, -1, -1):
            sugar = k
            total = water + sugar
            if (water // 100) * E < sugar or F < total or not dp[1][k]:
                continue
            else:
                if (ans_sugar == 0 and ans_total == 0) or sugar * ans_total > total * ans_sugar:
                    ans_sugar = sugar
                    ans_total = total
                    break
print(ans_total, ans_sugar)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
x=set()
for i in range(0,f+1,a):
    for j in range(0,f+1,b):
        if 0<(i+j)<=f:
            x.add(i+j)
y=set()
for i in range(0,f+1,c):
    for j in range(0,f+1,d):
        if 0<(i+j)<=f:
            y.add(i+j)

ans=[]
for n in x:
    for m in y:
        if n+m>f:
            continue
        if n*e<m*100:
            continue
        ans.append([n+m,m,m/n])
if not ans:
    print(a,0)
    exit()
ans.sort(key=lambda x:x[2], reverse=True)

print(ans[0][0],ans[0][1])

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

water = set()
suger = set()

for i in range(f+1):
    for j in range(f+1):
        x = 100 * (a * i + b * j)
        if x <= f:
            water.add(x)

for i in range(f+1):
    for j in range(f+1):
        y = c * i + d * j
        if y <= f:
            suger.add(y)


conc = 0
S = 0
W = 0

for s in suger:
    for w in water:
        if s + w > f:
            continue
        if s + w == 0:
            continue
        if  s > (w / 100)*e:
            continue
        temp = 100 * s / (s + w)
        if temp >= conc:
            conc = temp
            W = w
            S = s

print(S + W, S)

Solution (Python):
from bisect import bisect
a,b,c,d,e,f=map(int,input().split())
g=f//100
lst=[0]*(g+1)
i=0
for i in range(31):
    for j in range(31):
        h=a*i+b*j
        if h<=g:
            lst[h]=1
data=[]
for i in range(g*e//c):
    for j in range(g*e//d):
        data.append(c*i+d*j)
if not data:
    data=[0]
data.sort()
ans=-1
z=[]
for i in range(1,g+1):
    if lst[i]==0:
        continue
    k=100*i
    m=bisect(data,i*e)
    if m==0:
        continue
    o=data[m-1]
    if k+o<=f:
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
    else:
        m=bisect(data,f-k)
        o=data[m-1]
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
print(*z)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
s, w = (0, 100 * A)
water_list = [False] * (6000)
sugar_list = [False] * (6000)
water_list[0] = True
sugar_list[0] = True
for i in range(F):
    water_list[i + A * 100] = water_list[i + A * 100] or water_list[i]
    water_list[i + B * 100] = water_list[i + B * 100] or water_list[i]
    sugar_list[i + C] = sugar_list[i + C] or sugar_list[i]
    sugar_list[i + D] = sugar_list[i + D] or sugar_list[i]

for wi in range(0, F + 1, 100):
    for si in range(F + 1):
        if si * 100 <= wi * E and si + wi <= F and water_list[wi] and sugar_list[si]:
            if si * (s + w) > s * (si + wi):
                s, w = (si, wi)
print('{} {}'.format(s + w, s))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
s, w = (0, 0)
water_list = [False] * (6000)
sugar_list = [False] * (6000)
water_list[0] = True
sugar_list[0] = True
for i in range(F):
    water_list[i + A * 100] = water_list[i + A * 100] or water_list[i]
    water_list[i + B * 100] = water_list[i + B * 100] or water_list[i]
    sugar_list[i + C] = sugar_list[i + C] or sugar_list[i]
    sugar_list[i + D] = sugar_list[i + D] or sugar_list[i]

for wi in range(0, F + 1, 100):
    for si in range(F + 1):
        if si * 100 <= wi * E and si + wi <= F and water_list[wi] and sugar_list[si]:
            if (si * (s + w) >= s * (si + wi)) or (s == 0 and si > 0):
                s, w = (si, wi)
print('{} {}'.format(s + w, s))

Solution (Python):
from sys import stdin
import math
A, B, C, D, E, F = [int(x) for x in stdin.readline().rstrip().split()]

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

sugar = set()
capa = math.ceil(F/100)*E
for k in range(0, capa//C+1):
    for l in range(0, capa//D+1):
        sugar.add(C*k+D*l)

W = 0
S = 0
conc = 0


for w in water:
    for s in sugar:
        if w + s > F:
            continue
        if w+s == 0:
            continue
        if s > (w / 100)*E:
            continue
        tmp = (100*s)/(w+s)
        if tmp >= conc:
            conc = tmp
            W = w
            S = s
        
print(W+S,S)

Solution (Python):
from sys import stdin
import math
A, B, C, D, E, F = [int(x) for x in stdin.readline().rstrip().split()]

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

sugar = set()
capa = math.ceil(F/100)*E
for k in range(0, capa//C+1):
    for l in range(0, capa//D+1):
        sugar.add(C*k+D*l)

W = 0
S = 0
conc = 0


for w in water:
    for s in sugar:
        tmp = 0
        if w + s > F:
            continue
        if w+s == 0:
            continue
        if s > (w / 100)*E:
            continue
        tmp = (100*s)/(w+s)
        if tmp >= conc:
            conc = tmp
            W = w
            S = s
        
print(W+S,S)

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

water = set()
for i in range(F//(100*A) + 1):
    for j in range(F // (100*B) + 1):
        if 100*A * i + 100*j*B <= F:
            water |= {100*A * i + 100*j*B}
        else:
            break

sugar = set()
for i in range(F//C + 1):
    for j in range(F // D + 1):
        if C * i + D*j <= F:
            sugar |= {C * i + D*j}
        else:
            break
ans = [100*A, 0]
for x in water:
    if x == 0:
        continue
    for y in sugar:
        if x + y <= F and y <= (x/100)*E:
            if ans[1]/ans[0] < y / (x+y):
                ans = [x+y, y]

print(ans[0], ans[1])

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







def s_max(w):
    ret1 = e*w/100
    ret2 = f-w
    s = min(int(ret1),int(ret2)) 
    dp = [False]*(s+1)
    dp[0] = True
    for i in range(s+1):
        for j in range(s+1):
            if j + i*c <= s:
                dp[j+i*c] = dp[j]
    for i in range(s+1):
        for j in range(s+1):
            if j + i*d <= s:
                dp[j+i*d] = dp[j+i*d] or dp[j]
    ret = 0 
    for i in range(s+1):
        if dp[i]: ret = i
    return ret

dp = [False] * ((f//100)+1)
dp[0] = True
for i in range(30):
    for j in range(f+1):
        if j+i*a <= f//100:
            dp[j+i*a] = dp[j]
for i in range(30):
    for j in range(f+1):
        if j+i*b <= f//100:
            dp[j+i*b] = dp[j]

nmax = (0,(a*100,0))
for i in range((f//100)+1):
    if dp[i]:
        w = i*100
        s = s_max(i*100)
        if w+s == 0:
            continue
        if nmax[0] <= s/(s+w):
            nmax = (s/(s+w),(s+w,s))
print(*nmax[1])

Solution (Python):
def main():
    a, b, c, d, e, f = map(int, input().split())
    sugar = 0
    water = 0
    con = 0
    for i in range(f//100+1):
        if i%b == 0 or i%a == 0:
            w = i*100
            x = min(f-w, i*e)
            s = 0
        for j in range(x//c+1):
            ss = j*c
            s = max(s,ss+((x-ss)//d)*d)
        if w != 0:
            if con <= (100*s)/(w+s):
                water = w
                sugar = s
                con = (100*s)/(w+s)
    print(sugar+water, sugar)

if __name__ == "__main__":
    main()

Solution (Python):

import sys


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    A_enable = []
    B_enable = []
    AB_enable = []
    a = 0
    while a <= F:
        A_enable.append(a)
        a += A*100
    
    b = 0
    while b <= F:
        B_enable.append(b)
        b += B*100

    for aa in A_enable:
        for bb in B_enable:
            if aa+bb<=F:
                AB_enable.append(aa+bb)
    AB_enable = sorted(list(set(AB_enable)))
    AB_enable.pop(0)

    C_enable = []
    D_enable = []
    CD_enable = []
    c = 0
    while c <= F:
        C_enable.append(c)
        c += C
    d = 0
    while d <= F:
        D_enable.append(d)
        d += D

    for cc in C_enable:
        for dd in D_enable:
            if cc+dd <= F:
                CD_enable.append(cc+dd)
    CD_enable = sorted(list(set(CD_enable)))
    CD_enable.pop(0)

    answer = [AB_enable[0],0,0] 

    for aabb in AB_enable:
        for ccdd in CD_enable:
            if (aabb/100)*E >= ccdd and aabb+ccdd<=F and answer[2] < ccdd/(aabb+ccdd): 
                
                answer[0] = aabb
                answer[1] = ccdd
                answer[2] = ccdd/(aabb+ccdd)
    
    print(answer[0]+answer[1], answer[1])
            
    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_m=int((f*100/(100+e)))//100*100
s_m=f*e//(100+e)
answ=100*a
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if i==0 and j==0:
            w=min(100*a,100*b)
            s_m=f-w
        for k in range(s_m//c+1):
            for l in range((s_m-k*c)//d+1):
                s=k*c+l*d
                if (anss*(s+w)<s*(anss+answ)) and (s*(100+e)<=e*(s+w)):
                    answ=w
                    anss=s
print(answ+anss,anss)

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

water_list = []
suger_list = []

for i in range(F):
  if 100*A*i <= F:
    for j in range(F):
      if 100*B*j <= F:
        if 100*A*i + 100*B*j <= F:
          water_list.append(100*A*i + 100*B*j)
        else:
          break
      else:
        break
  else:
    break

for i in range(F):
  if C*i <= F:
    for j in range(F):
      if D*j <= F:
        if C*i + D*i <= F:
          suger_list.append(C*i+D*j)
        else:
          break
      else:
        break
  else:
    break

ans = 0
ans_list = []

for water in water_list:
  for suger in suger_list:
    if water != 0 and suger != 0:
      if suger/(water + suger) >= ans and water+suger <= F and suger <= (water/100)*E:
        ans = suger/(water + suger)
        ans_list = [water,suger]

if ans != 0:
  print(str(ans_list[0]+ans_list[1]) + " " + str(ans_list[1]))
else:
  print(str(A*100) + " 0")

Solution (Python):
a,b,c,d,e,f=[int(x) for x in input().split()]
a=100*a
b=100*b
ans = 0
v = 0
su = 0
for i in range(f//a+1):
  for j in range((f-a*i)//b+1):
    for k in range((e*(i*a//100+j*b//100))//c+1):
      for l in range((e*(a*i//100+j*b//100)-k*c)//d+1):
        if (i!=0 or j!=0 or k!=0 or l!=0) and ans<=(c*k+l*d)/(a*i+b*j+c*k+l*d) and (a*i+b*j+c*k+l*d)<=f:
          ans=(c*k+l*d)/(a*i+b*j+c*k+l*d)
          v = (a*i+b*j+c*k+l*d)
          su = c*k+l*d
print(v,su)

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

max_a = f // (a*100)
for i in range(max_a + 1):
  max_b = (f- i*a*100) // (b*100)
  for j in range(max_b + 1):
    water = i*a*100 + j*b*100
    if water == 0:
      continue
    suger = min(e * (water /100), f - water)
    max_c = int(suger // c)
    for k in range(max_c + 1):
      l = (suger - k * c) // d
      if (k*c + l*d) / water > (e / 100):
        continue
      if max_set[0] < (k*c + l*d) / water:
        max_set[0] = (k*c + l*d) / water
        max_set[1] = int((k*c + l*d) + water)
        max_set[2] = int((k*c + l*d))

if max_set[0] == 0 and max_set[1] == 0:
  print(100*a, 0)
else:
  print("{} {}".format(max_set[1], max_set[2]))

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
W=set()
for a in range(0,F+1,100*A):
    for b in range(0,F+1-a,100*B):
        W.add(a+b)
S=set()
for c in range(0,F+1,C):
    for d in range(0,F+1-c,D):
        S.add(c+d)
mx=-1
for w in W:
    for s in S:
        if 0<w+s<=F and s<=w*E//100:
            if mx<s/(w+s):
                ans=w+s,s
                mx=s/(w+s)
print(ans[0],ans[1])

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
tres = -1
res = [0,0]
for i in range(31):
    mass = i * 100*b
    if mass > f:
        break
    for j in range(31):
        mass = i * 100*b+100*a*j
        if mass > f:
            break
        if mass == 0:
            continue
        for k in range(101):
            mass = i * 100*b+100*a*j + k*d
            sugar = k*d
            if mass > f:break
            l = min(int((mass - sugar)*e/100 - k*d)//c, (f - mass)//c)
            if l < 0: break
            mass += l * c
            sugar += l*c
            noudo = sugar / mass
            if noudo > tres:
                tres = noudo
                res[0] = mass
                res[1] = sugar
                
print(" ".join(map(str,res)))

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

dic_w={}
i=0
while True:
    if (a*i*100)>f:
        break
    j=0
    while True:
        w=(a*i+b*j)*100
        if w==0:
            j+=1
            continue
        if w>f:
            break
        else:
            dic_w[w]=dic_w.get(w,0)+1
        j+=1
    i+=1
list_w=list(dic_w.keys())
list_w.sort()

dic_s={}
max_s=int(e*f/(100+e)+1)
i=0
while True:
    if c*i>max_s:
        break
    j=0
    while True:
        s=c*i+d*j
        if s>max_s:
            break
        else:
            dic_s[s]=dic_s.get(s,0)+1
        j+=1
    i+=1
list_s=list(dic_s.keys())
list_s.sort()

max_per=0
flag=False
ans_w=0
ans_s=0
for w in list_w:
    if flag==True:
        break
    for s in list_s:
        if s/(w/100)==e and s+w<=f:
            ans_w=w
            ans_s=s
            flag=True
            break
        if s/(w/100)>e:
            break
        if 100*s/(s+w)>=max_per and s+w<=f:
            ans_w=w
            ans_s=s
            max_per=100*s/(s+w)
print('{} {}'.format(ans_w+ans_s,ans_s))

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

water = []
sugar =[]
ans = [-1] * 3
for i in range(F+1):
    for j in range(F+1):
        y = i * C + j * D
        if y <= F:
            sugar.append(y)

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

for i in range(len(water)):
    for j in range(len(sugar)):
        a = water[i]
        b = sugar[j]
        if a + b <= F and a / 100 * E >= b:
            if ans[0] * (a + b) < 100 * b:
                ans[0] = 100 * b / (a + b)
                ans[1] = a + b
                ans[2] = b
print("{} {}".format(ans[1], ans[2]))

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

res = [100 * a, 0]
for x0 in range(31):
    for x1 in range(16):
        for x3 in range(1501):
            t1 = e*a*x0+e*b*x1-d*x3
            t2 = f-100*a*x0-100*b*x1-d*x3
            x2 = min(t1,t2) // c
            if x2 >= 0 and \
                (c*x2+d*x3)*res[0]-(100*a*x0+100*b*x1+c*x2+d*x3)*res[1]>0:
                res[0] = 100*a*x0+100*b*x1+c*x2+d*x3
                res[1] = c*x2+d*x3

print('{f} {s}'.format(f=res[0],s=res[1]))

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
p = -1
a = [0,0]

for i in range(0,F+1,A*100):
    for j in range(0,F+1-i,B*100):
        for k in range(0,int(E*(i+j)/100)+1,C):
            for l in range(0,int(E*(i+j)/100)+1-k,D):
                if i+j+k+l > F:
                    continue
                if i+j > 0 and p < (k+l) / (i+j+k+l):
                    p = (k+l) / (i+j+k+l)
                    a = [i+j+k+l,k+l]
print(a[0],a[1])

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

n_sugar = set()
max_sugar = math.ceil(E*F/100)
for i in range(max_sugar//C + 1):
    for j in range(max_sugar//D + 1):
        if C*i + D*j <= max_sugar:
            n_sugar.add(C*i + D*j)
            
n_water = set()
for i in range(F//(100*A) + 1):
    for j in range(F//(100*B) +1):
        if 100*A*i + 100*B*j <= F:
            n_water.add(100*A*i + 100*B*j)
            
n_sugar = list(n_sugar)
n_water.remove(0)
n_water = list(n_water)

ans_list = []
for sugar in n_sugar:
    for water in n_water:
        if sugar + water <= F and sugar <= E*water/100:
            ans_list.append([sugar+water, sugar, sugar/(sugar+water)])
            
ans_list = sorted(ans_list, key = lambda x: x[2], reverse = True)

print(ans_list[0][0], ans_list[0][1])

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

G = F//100
water = []
for W in range(A,G+1):
    for a in range(G//A+1):
        for b in range(G//B +1):
            if a*A+b*B == W:
                water.append(W)

noudo = 0
ans = (100*A,0)

for W in water:
    sugerlimit = min(W*E,F-100*W)
    for c in range(sugerlimit//C,-1,-1):
        for d in range(sugerlimit//D,-1,-1):
            if c*C+d*D > sugerlimit:
                pass
            else:
                noudo2 = 100*(c*C+d*D)/(100*W+c*C+d*D)
                if noudo2>noudo:
                    ans = (100*W+c*C+d*D,c*C+d*D)
                    noudo = noudo2
                break

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