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())
wa = []
for ia in range(30):
    for ib in range(30):
        if 100*(ia*a+ib*b) <= f and not 100*(ia*a+ib*b) in wa:
            wa.append(ia*a+ib*b)

msu = [0 for i in range(len(wa))]
mc = -0.01
mci = -1
for i,w in enumerate(wa):
    for ic in range(1501):
        for id in range(1501):
            if ic*c+id*d > e*w:
                break
            if ic*c+id*d+w*100 > f:
                break
            if msu[i] < ic*c+id*d:
                msu[i] = ic*c+id*d
                if mc < (ic*c+id*d)/(ic*c+id*d+w*100):
                    mc = (ic*c+id*d)/(ic*c+id*d+w*100)
                    mci = i

print(wa[mci]*100+msu[mci],msu[mci])

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

def calc(a, b):
    if a == 0 or b == 0: return 0
    return 100 * b / (a + b)
ans = (0, 0)
tmp = 0
ret = set()
for i in range(3001):
    for j in range(3001):
        water = i * A * 100 + j * B * 100
        if 1 > water or water > F: break
        for k in range((F-water)//C+1):
            for l in range((F-water)//D+1):
                suger = k * C + l * D
                if water + suger > F: break
                if water * E // 100 < suger: break
                t = calc(water, suger)
                
                if tmp <= t:
                    tmp = t
                    ans = (water+suger, suger)



print(*ans)

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

possible_water = []
for i in range(31):
    for j in range(31):
        water = 100*a*i + 100*b*j
        if 0 < water <= f:
            possible_water.append(water)
pw = list(set(possible_water))

possible_sugar = []
for i in range(3001):
    for j in range(3001):
        sugar = c*i + d*j
        if sugar <= f:
            possible_sugar.append(sugar)
ps = list(set(possible_sugar))

ans = []
for i in pw:
    for j in ps:
        if i + j <= f and j <= (i//100)*e:
            c = 100*j/(i+j)
            ans.append([c,i+j,j])

ans.sort(reverse=True)
print(ans[0][1],ans[0][2])

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    max_deisity = 100 * E / (100 + E)
    MAX = -1
    W = 0
    S = 0
    for a in range(F // (100 * A) + 1):
        rest1 = F - a * A * 100
        for b in range(rest1 // (100 * B) + 1):
            if a == 0 and b == 0:
                continue

            water = a * A * 100 + b * B * 100
            rest2 = F - water
            for c in range(rest2 // C + 1):
                rest3 = rest2 - C * c
                for d in range(rest3 // D + 1):
                    sugar = C * c + D * d

                    if water + sugar > F:
                        continue

                    density = 100 * sugar / (water + sugar)
                    if max_deisity < density:
                        continue

                    if density > MAX:
                        MAX = density
                        W = water
                        S = sugar

    print(W + S, S)


if __name__ == "__main__":
    main()

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
w=set()
s=set()
sw=0
sws=0
sww=0
for i in range(F//(100)):
    for j in range(F//(100)):
        w.add(i*100*A+j*100*B)
for i in range(F//C):
    for j in range(F//D):
        s.add(i*C+j*D)
s=list(s)
w=list(w)
for i in range(len(w)):
    for j in range(len(s)):
        if w[i]+s[j]!=0:
            tmp=(s[j]*100)/(w[i]+s[j])
            if sw <= tmp <= (E*100)/(100+E) and F >= w[i]+s[j]:
                sw =tmp
                sww= w[i]+s[j]
                sws = s[j]
print(sww,sws)

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    a,b,c,d,e,f=map(int,readline().split())

    w=[]
    for i in range(0,f+1,100):
        for j in range(0,f+1,100):
            n=a*i+b*j
            if n<=f:
                w.append(n)
    w.sort()

    s=[]
    for i in range(f+1):
        for j in range(f+1):
            n=c*i+d*j
            if n<=f:
                s.append(n)
    s.sort()

    cnt=-1
    res=[0,0]
    for x in w:
        for y in s:
            if x+y>f:
                break

            ma=x//100*e
            if y>ma:
                continue
            
            if (x+y)!=0 and cnt<100*y/(x+y):
                cnt=100*y/(x+y)
                res=[x+y,y]

    print(*res)

if __name__=="__main__":
    main()

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

water = []
sugar = []
for i in range(0,1000):
    for j in range(0,1000):
        if (100*i*a + 100*j*b ) <= f:
            water.append(100*i*a + 100*j*b)
        if c*i + d*j <= f:
            sugar.append(c*i+d*j)
        

water = list(set(water))
water.sort()
water.remove(0)
sugar = list(set(sugar))
sugar.sort()

concentration = 0
sgw = 0
sg = 0

x = e/100

for i in water:
    for j in sugar:
        temp = (100 * j) / (i + j)
        if concentration <= temp and i + j <= f and (i /100)*e  >= j:
            
            sgw = i + j
            sg = j
            concentration = temp
if sgw == 0:
    sgw = water[-1]
print(sgw,sg)

Solution (Python):
def dense(a, b):
	return b / (a+b)

def resolve():
	a, b, c, d, e, f = map(int, input().split())
	ws = set()
	ss = set()
	for i in range(31):
		for j in range(31):
			if a*100*i + b*100*j <= f:
				ws.add(a*100*i + b*100*j)
	for i in range(3001):
		for j in range(3001):
			if c*i + j*d <= f:
				ss.add(c*i + j*d)
	ans_w, ans_s = -1, 0
	lim = e / (100+e)
	for wv in ws:
		for sv in ss:
			if wv + sv > f:
				continue
			if wv + sv == 0:
				continue
			if lim >= dense(wv, sv):
				if dense(ans_w, ans_s) <= dense(wv, sv):
					ans_w, ans_s = wv, sv
	print(ans_w + ans_s, ans_s)
resolve()

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

w=[]
s=[]
for i in range(F):
    for j in range(F):
        a=100*A*i
        b=100*B*j
        if (a+b)>F:
            continue

        w.append(a+b)

for i in range(F):
    for j in range(F):
        c=C*i
        d=D*j
        if (c+d)>F:
            continue
        s.append(c+d)
ans=0.0
l=[100*A,0]
for water in w:
    for sugar in s:
        p=water+sugar
        if p==0:
            continue
        if p>F:
            continue 
        val=sugar/p
        if val<=(E/(100+E)):
            if ans<val:
                ans=val
                l=[p,sugar]

print(*l)

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

ws = set()
ss = set()
for a in range(0, F+1, A*100):
    for b in range(0, F+1-a, B*100):
        ws.add(a + b)

for c in range(0, F+1, C):
    for d in range(0, F+1-c, D):
        ss.add(c + d)

mx = -1
ans = 0, 0
for w in ws:
    if w == 0:
        continue
    for s in ss:
        x = s * 100 / w
        if w + s <= F and x <= E and mx < x:
            mx = x
            ans = s + w, s

print(*ans)

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

ws = set()
ss = set()
for a in range(0, F+1, A*100):
    for b in range(0, F+1-a, B*100):
        ws.add(a + b)

for c in range(0, F+1, C):
    for d in range(0, F+1-c, D):
        ss.add(c + d)

mx = -1
ans = 0, 0
for w in ws:
    if w == 0:
        continue
    for s in ss:
        x = s * 100 / w
        if w + s <= F and x <= E and mx < x:
            mx = x
            ans = s + w, s

print(*ans)

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, 100*B):
        W.add(a+b)
S = set()
for c in range(0, F+1, C):
    for d in range(0, F+1, D):
        S.add(c+d)

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

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

    
    wt = set()
    sg = set()
    for i in range(0, F+1, 100*A):
        for j in range(0, F+1, 100*B):
            if 0 < i + j and i + j <= F:
                wt.add(i + j)
    for i in range(0, F+1, C):
        for j in range(0, F+1, D):
            
            if i + j <= F:
                sg.add(i + j)

    
    ans_t, ans_s = -1, -1
    concent = -1
    for w in wt:
        for s in sg:
            if F < w + s: continue  
            if E * w // 100 < s: continue  
            if concent < s / (w + s):
                ans_t, ans_s = w + s, s  
                concent = s / (w + s)

    print('{} {}'.format(ans_t, ans_s))

abc083_c()

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)
rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= w*E//100:
            if s/(w+s) > rate:
                rate = s/(w+s)
                ans = w+s, s
print(ans[0],ans[1])

Solution (Python):
def dense(w, s):
	if s + w == 0:
		return 0
	return s / (w + s) * 100

def resolve():
	A, B, C, D, E, F = map(int, input().split())
	waters = set()
	sugars = set()

	for i in range(31):
		for j in range(31):
			v = A*i*100 + B*j*100
			if v > F:
				continue
			waters.add(v)
	for i in range(3001):
		for j in range(3001):
			v = i*C + j*D
			if v > F:
				continue
			sugars.add(v)
	ans_w, ans_s = 0, 0
	for w in waters:
		for s in sugars:
			if w + s > F or s > w//100*E or s + w == 0:
				continue
			if dense(w, s) >= dense(ans_w, ans_s):
				ans_w, ans_s = w, s
	print(ans_w + ans_s, ans_s)
resolve()

Solution (Python):
def dense(w, s):
	if s + w == 0:
		return 0
	return s / (w + s) * 100

def resolve():
	A, B, C, D, E, F = map(int, input().split())
	waters = set()
	sugars = set()

	for i in range(31):
		for j in range(31):
			v = A*i*100 + B*j*100
			if v > F:
				continue
			waters.add(v)
	for i in range(101):
		for j in range(101):
			v = i*C + j*D
			if v > F:
				continue
			sugars.add(v)
	ans_w, ans_s = 0, 0
	for w in waters:
		for s in sugars:
			if w + s > F or s > w//100*E or s + w == 0:
				continue
			if dense(w, s) >= dense(ans_w, ans_s):
				ans_w, ans_s = w, s
	print(ans_w + ans_s, ans_s)
resolve()

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

water = [0 for _ in range(f+1)]
sugure = [0 for _ in range(f+1)]
i = 0
while 100 * a * i <= f:
    j = 0
    while 100 * a * i + 100 * b * j <= f:
        water[100 * a * i + 100 * b * j] = 1
        j += 1
    i += 1
i = 0
while c * i <= f:
    j = 0
    while c * i + d * j <= f:
        sugure[c * i + d * j] = 1
        j += 1
    i += 1

ans = []
for i in range(1, f+1):
    if water[i]:
        j = 0
        tmp = 0
        i_ans = [0, 0, 0]
        while 100 * j / (i + j) <= e * 100 / (100 + e) and j <= f and i + j <= f:
            if sugure[j]:
                i_ans = [100 * j / (i + j), i, j]
            j += 1
        ans.append(i_ans)
ans.sort(reverse=True)
ans = ans[0]
print(ans[1]+ans[2], ans[2])

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C,D,E,F = list(map(int,_in[0].split(' ')))  
    
    per = -1
    for a in range(0,F+1,100*A):
        for b in range(0,F+1,100*B):
            if a+b == 0:
                break
            for c in range(0,F+1,C):
                for d in range(0,F+1,D):
                    if a+b+c+d>F:
                        break
                    elif (c+d)/(a+b)>E/100:
                        break
                    else:
                        if per < (c+d)/(a+b+c+d):
                            per = (c+d)/(a+b+c+d)
                            cnt = [a+b+c+d, c+d]
    
    print(cnt[0],cnt[1])

Solution (Python):
a,b,c,d,e,f = map(int,input().split())
ans_per, ans_w, ans_s = -1,0,0
for i in range(f//(100*a) + 1):
  for j in range((f-100*i)//(100*b) + 1):
    if i == j == 0:
      continue
    w = i*a*100 + j*b*100
    r = min(f-w, w//100 * e)
    for x in range(r//c + 1):
      for y in range((r-x*c)//d + 1):
        s = x*c + y*d
        if s / w > ans_per:
          ans_per = s/w
          ans_w = w
          ans_s = s
print('{} {}'.format(ans_w+ans_s, ans_s))

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

water = set()
sugar = set()

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

for i in range(0, F+1, C):
    for j in range(0, F+1-C, D):
        sugar.add(i+j)

per = -1
for w in water:
    for s in sugar:
        ws = w+s
        
        if 0 < ws <= F and s <= w*E // 100:
            if s/(ws) > per:
                per = s/(ws)
                ans = ws, s

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

Solution (Python):


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

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

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

def sub(s, c, d):
    
    k3 = s//c
    k4 = 0
    val = k3 * c + k4 * d
    best = val
    k4 += 1
    while k3>=0:
        val = k3 * c + k4 * d
        if val > s:
            k3 -= 1
        else:
            best = max(val, best)
            k4 += 1
    return best
    
best = (0, 100*a, 0)
k1 = 0
while True:
    k2 = 0
    while True:
        w = 100*k1*a + 100*k2*b
        if w==0:
            k2 += 1
            continue
        if w>f:
            break
        s = min(f - w, int(w*e / 100))
        val = sub(s, c, d)

        if best[0] < val/(w+val):
            best = (val/(w+val), w, val)
        k2 += 1
    k1+=1
    if 100*k1*a>f:
        break
print(best[1]+best[2], best[2], sep=" ")

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

waterL=[]
ac=0
while a*100*ac<=f:
    bc=0
    while a*100*ac+b*100*bc<=f:
        waterL.append(a*100*ac+b*100*bc)
        bc += 1
    ac += 1
waterL.remove(0)
ma=0
ms=0
mw=0
for w in waterL:
    lim=w/100*e
    cc=0
    while c*cc<=lim and c*cc+w<=f:
        dc=0
        while cc*c+dc*d<=lim and c*cc+d*dc+w<=f:
            s=c*cc+d*dc
            per=s/(w+s)
            if per>=ma:
                ma=per
                ms=s
                mw=w
            dc += 1
        cc += 1
print(int(ms+mw),int(ms))

Solution (Python):
A, B, C, D, E, F = map(int,input().split())
water = [0 for _ in range(31)]
sugar = [0 for _ in range(3001)]
water[0] = 1
sugar[0] = 1
for i in range(30):
    if water[i] == 0:
        continue
    if i + A <= 30:
        water[i+A] = 1
    if i + B <= 30:
        water[i+B] = 1
for i in range(3000):
    if sugar[i] == 0:
        continue
    if i + C <= 3000:
        sugar[i+C] = 1
    if i + D <= 3000:
        sugar[i+D] = 1

MAX = -1
ans = None
for i in range(1, 31):
    for j in range(3001):
        if water[i] == 0 or sugar[j] == 0 or i * 100 + j > F or i * E < j:
            continue
        if MAX < 100 * j / (j + i * 100):
            MAX = 100 * j / (j + i * 100)
            ans = [i * 100 + j, j]
print(*ans)

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





V=0
node=0
total=0
sugar=0

for a in range(F//(100*A)+1):
    for b in range((F-100*A*a)//(100*B)+1):
        v=F-100*A*a-100*B*b
        for c in range(v//C+1):
            v2=v-c*C
            for d in range(v2//D+1):
                v3=v2-d*D
                if v3<0:
                    continue
                if a==0 and b==0:
                    continue
                if (c*C+d*D)/(a*A+b*B)>E:
                    continue
                nownode=100*(c*C+d*D)/(F-v3)
                if nownode>=node:
                    node=nownode
                    total=F-v3
                    sugar=(c*C+d*D)

print(total, sugar)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
xmax = 100*A
kmax = 0
for n in range(31):
    for m in range(31):
        x = 100*(n*A+m*B)
        ymax = min((n*A+m*B)*E,F-100*(n*A+m*B))
        for k in range(ymax,ymax-C-1,-1):
            t = 0
            flag = 0
            while k-t*D>=0:
                if (k-t*D)%C==0:
                    flag = 1
                    break
                t += 1
            if flag==1:
                if kmax*(x+k)<k*(xmax+kmax):
                    xmax = x
                    kmax = k
print(xmax+kmax,kmax)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,d,e,f = inpl()
mx = 0
res = 0
ans = 0
for i in range(40):
    for j in range(40):
        water = 100*a*i + 100*b*j
        if water == 0:
            continue
        for k in range(300):
            for l in range(300):
                sugar = c*k + d*l
                if water+sugar > f or sugar > (a*i+b*j)*e:
                    continue
                if sugar/(water+sugar) >= mx:
                    mx = sugar/(water+sugar)
                    res = water+sugar
                    ans = sugar
print(res,ans)

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

total = 100 * A
sugar = 0

for a in range(F// (100 * A) + 1):
    for b in range((F - (100 * a)) // (100 * B) + 1):
        tmp_water = 100 * (A * a + B * b)
        if tmp_water == 0:
            continue
        
        maxC = min(tmp_water // 100 * E, F - tmp_water) 
        
        if maxC <= 0:
            continue

        

        for c in range(0, maxC + 1, C): 
            
            left = maxC - c
            d = (left // D) * D
            tmp_sugar = c + d
            tmp_total = tmp_sugar + tmp_water
            if sugar * tmp_total < tmp_sugar * total:
                total = tmp_total
                sugar = tmp_sugar

print (total, sugar)

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

max_nodo = 0
ans = [100*a, 0]
for i in range(30//a+1):
    for j in range(30//b+1):
        mizu = 100*i*a + 100*j*b
        if mizu > f: break
        if mizu == 0: continue
        maxi = (i*a + j*b) * e
        for k in range(maxi//c+1):
            for l in range(maxi//d+1):
                sato = c*k + d*l
                if mizu+sato > f: break
                if sato > maxi: break
                nodo = sato / (mizu+sato)
                if nodo > max_nodo:
                    max_nodo = nodo
                    ans = [mizu+sato, sato]

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

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

dp = [-1] * (F + 1)  
dp[0] = 0

for f in range(F + 1):
    if A + f <= F:
        dp[A + f] = max(dp[A + f], dp[f])
    if B + f <= F:
        dp[B + f] = max(dp[B + f], dp[f])
    if C + f <= F and dp[f] >= 0:
        water = f - dp[f]
        maxSugar = (water // 100) * E
        if dp[f] + C <= maxSugar:
            dp[C + f] = max(dp[C + f], dp[f] + C)
    if D + f <= F and dp[f] >= 0:
        water = f - dp[f]
        maxSugar = (water // 100) * E
        if dp[f] + D <= maxSugar:
            dp[D + f] = max(dp[D + f], dp[f] + D)

ans = (0, 0)
mx = -1
for f in range(1, F + 1):
    if mx < 100 * dp[f] / f:
        mx = 100 * dp[f] / f
        ans = (f, dp[f])
print(*ans)

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

water = [0]*(f+1)
suger = [0]*(f+1)
water[0] = 1
suger[0] = 1
for i in range(f+1):
    if water[i]:
        if i+100*a <= f:
            water[i+100*a] = 1

        if i+100*b <= f:
            water[i+100*b] = 1
    if suger[i]:
        if i+c <= f:
            suger[i+c] = 1
        if i+d <= f:
            suger[i+d] = 1

water_ls = [i for i in range(f+1) if water[i]]
suger_ls = [i for i in range(f+1) if suger[i]]

suger_water = []
max_c = 100*e/(100+e)
for w in water_ls:
    for s in suger_ls:
        if f < w+s:
            continue
        if w+s == 0:
            continue
        if s*(100+e) <= e*(w+s):
            c = 100*s/(w+s)
            suger_water.append((c, w, s))

suger_water.sort(reverse=True)
max_c, w, s = suger_water[0]
print(w+s, s)

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

ws = set()
for a in range(F+1):
    if a*100*A > F: break
    for b in range(F+1):
        if a*100*A + b*100*B > F: break
        ws.add(a*100*A + b*100*B)

ss = set()
for c in range(F+1):
    if c*C > F: break
    for d in range(F+1):
        if c*C + d*D > F: break
        ss.add(c*C + d*D)

os = -1
ow = 999
for w in ws:
    if w==0: continue
    for s in ss:
        if s+w > F: continue
        if w*E < s*100: continue
        if os * (s+w) < s * (os+ow):
            os,ow = s,w
print(os+ow, os)

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

set_ = set()
for i in range(3000):
    for j in range(3000):
        set_.add(c * i + d * j)

ans_noudo = -1
w = -1
s = -1
for i in range(31):
    for j in range(31):
        water = 100 * a * i + 100 * b * j
        if water == 0:
            continue
        if water > f:
            continue
        nokori = f - water
        for suger in range(0, nokori + 1):
            if suger not in set_:
                continue
            if water * e < suger * 100:
                continue
            noudo = 100 * suger / (water + suger)
            if ans_noudo < noudo:
                ans_noudo = noudo
                w = water
                s = suger
print(w + s, s)

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)
rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= w*E//100:
            if s/(w+s) > rate:
                rate = s/(w+s)
                ans = w+s, s
print(ans[0],ans[1])

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

def main():
    A, B, C, D, E, F = map(int, readline().rstrip().split())
    X = set()
    for a in range(F//(100*A)+1):
        for b in range(F//(100*B)+1):
            if 100 * a * A + 100 * b * B <= F:
                X.add(100 * a * A + 100 * b * B)
    X.remove(0)

    Y = set()
    for c in range(F//C+1):
        for d in range(F//D+1):
            if c * C + d * D <= F/2:
                Y.add((c * C + d * D))

    ans = (0, 0)
    max_dens = -1
    for x in X:
        for y in Y:
            if x + y > F:
                continue
            if y * 100 <= x * E:
                dens = y/(x+y)
                if dens > max_dens:
                    ans = (x+y, y)
                    max_dens = dens
    print(*ans)

if __name__ == '__main__':
    main()

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,100*B):
    W.add(a+b)
S = set()
for c in range(0,F+1,C):
  for d in range(0,F+1,D):
    S.add(c+d)
rate = -1
for w in W:
  for s in S:
    if 0 < w+s <= F and s*100 <= E*w:
      if s/(s+w) > rate:
        rate = s/(s+w)
        ans = w+s,s
print(ans[0],ans[1])

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

s = set()
t = set()
for i in range(0, f+1,  100 * a):
    for j in range(0, f + 1 - a, 100 * b):
        s.add(i + j)


for k in range(0, f + 1, c):
    for l in range(0, f + 1, d):
            t.add(k + l)
mi = -1
ans = [str(0), str(0)]
for n in s:
    for m in t:
        if 0 < n + m <= f and m <= n * e // 100:
            if m /(n + m) > mi:
                mi = m / (n + m)
                ans = [str(n + m), str(m)]

print(" ".join(ans))

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,D):
        S.add(c+d)
rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= w*E//100:
            if s/(w+s) > rate:
                rate = 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=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,D):
        S.add(c+d)
rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= w*E//100:
            if s/(w+s) > rate:
                rate = s/(w+s)
                ans = w+s, s
print(ans[0],ans[1])

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
satoumizu=100*A
satou=0
for a in range(31):
  for b in range(16):
    for c in range(F-100*A*a-100*B*b):
      for d in range(F-100*A*a-100*B*b-C*c):
        if a==0 and b==0 and c==0 and d==0:
          continue
        if E*(A*a+B*b)>=C*c+D*d and 100*(A*a+B*b)+C*c+D*d<=F:
          if (C*c+D*d)/(100*(A*a+B*b)+C*c+D*d)>satou/satoumizu:
            satoumizu=100*(A*a+B*b)+C*c+D*d
            satou=C*c+D*d
print(satoumizu,satou)

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

best_sugarwater = 100*A
best_sugar = 0
best_con = 0
max_con = E/(100+E)

maxA = F//(100*A)
for i in range(maxA+1):
    maxB = (F-100*A*i)//(100*B)
    for j in range(maxB+1):
        water = 100*A*i+100*B*j
        maxC = (F-100*A*i-100*B*j)//C
        for k in range(maxC+1):
            maxD = (F-100*A*i-100*B*j-C*k)//D
            for l in range (maxD+1):
                sugar = C*k+D*l
                if sugar + water == 0 :
                    pass
                elif (best_con < sugar/(sugar + water) <= max_con ):
                    best_sugarwater = sugar + water
                    best_sugar = sugar
                    best_con = sugar/(sugar + water)

print(best_sugarwater,best_sugar)

Solution (Python):
a,b,c,d,e,f = map(int, input().split())
s_max = f*e//(e+100)
w_max = f//100

s=[]
w=[]

max = 0
ans = [100*a,0]
for i in range(s_max//c+1):
    for j in range(s_max//d+1):
        if c*i + d*j <= s_max:
            s.append(c*i + d*j)

for i in range(w_max//a+1):
    for j in range(w_max//b+1):
        if 0<a*i + b*j <= w_max:
            w.append(a*i + b*j)

for i in range(len(s)):
    for j in range(len(w)):
        if s[i]/(w[j]*100+s[i])<=e/(e+100) and s[i]/(w[j]*100+s[i])>=max and w[j]*100+s[i]<=f:
            max = s[i]/(w[j]*100+s[i])
            ans = [w[j]*100+s[i],s[i]]

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

Solution (Python):
A, B, C, D, E, F = map(int,input().split())
answer_number = [0,0,0,0]
answer_max = 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
    for k in range(((F-100*A*i-100*B*j)//C)+1):
      for l in range(((F-100*A*i-100*B*j-C*k)//D)+1):
        if (C*k+D*l)/(A*i+B*j) <= E:
          if (C*k+D*l)/(A*i+B*j) > answer_max:
            answer_max = (C*k+D*l)/(A*i+B*j)      
            answer_number = [i,j,k,l]
if answer_max == 0: print(100*A,0)
else:
  print(C*answer_number[2]+D*answer_number[3]+100*(A*answer_number[0]+B*answer_number[1]), C*answer_number[2]+D*answer_number[3])

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

cand_water=set()
for i in range(1,30//A+1):
  for j in range(30//B+1):
    vol=i*100*A+j*100*B
    if vol<=F:
      cand_water.add(vol)


cand_sugar=set()
if C==1 or D==1:
  cand_sugar=set(range(F+1))
else:
  for i in range(3000//C+1):
    for j in range(3000//D+1):
      vol=i*C+j*D
      if vol<=F:
        cand_sugar.add(vol)


max_concent=-1
answer=[0,0]
for water in cand_water:
  for sugar in cand_sugar:
    if water+sugar>F:
      continue
    if sugar/(water+sugar)>E/(100+E):
      continue
      
    if sugar/(water+sugar)>max_concent:
      answer=(water+sugar,sugar)
      max_concent=sugar/(water+sugar)
      
print(*answer)

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

cand_water=set()
for i in range(31):
  for j in range(31):
    vol=i*100*A+j*100*B
    if 0<vol<=F:
      cand_water.add(vol)


cand_sugar=set()
for i in range(3001):
  for j in range(3001):
    vol=i*C+j*D
    if 0<=vol<=F:
      cand_sugar.add(vol)


max_concent=-1
answer=[0,0]
for water in cand_water:
  for sugar in cand_sugar:
    if water+sugar>F:
      continue
    if sugar/(water+sugar)>E/(100+E):
      continue
      
    if sugar/(water+sugar)>max_concent:
      answer=(water+sugar,sugar)
      max_concent=sugar/(water+sugar)
      
print(*answer)

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,D):
        S.add(c+d)
rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= w*E//100:
            if s/(w+s) > rate:
                rate = s/(w+s)
                ans = w+s, s
print(ans[0],ans[1])