AtCoder Beginner Contest 074 - Sugar Water

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 2 10 20 15 200

-----Sample Output-----
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.

Difficulty: EASY

Starter code:

Solutions:
(A, B, C, D, E, F) = map(int, input().split())
water = set()
for a in range(0, F + 1, 100 * A):
	for b in range(0, F + 1, 100 * B):
		if a + b <= F:
			water.add(a + b)
water = sorted(list(water))
suger = set()
for c in range(0, F + 1, C):
	for d in range(0, F + 1, D):
		if c + d <= F:
			suger.add(c + d)
suger = sorted(list(suger))
(ans, answater, anssuger) = (0, 0, 0)
for w in water:
	for s in suger:
		if w // 100 * E < s or w + s > F:
			break
		if w + s != 0:
			if ans <= 100 * s / (w + s):
				(answater, anssuger) = (w + s, s)
				ans = 100 * s / (w + s)
print(answater, anssuger)


(a, b, c, d, e, f) = [int(x) for x in input().split()]
ans = 0
ans_s = 0
ans_all = 100 * a
wlist = []
slist = []
for i in range(f // (100 * a) + 1):
	for j in range((f - i * 100 * a) // (100 * b) + 1):
		wlist.append(100 * a * i + 100 * b * j)
for i in range(f * e // 100 // c + 1):
	for j in range(f * e // 100 // d + 1):
		slist.append(c * i + d * j)
wlist = set(wlist)
slist = set(slist)
for w in wlist:
	for s in slist:
		if w + s == 0:
			break
		if s * 100 / (w + s) > ans and w * e / 100 >= s and (w + s <= f):
			ans = s * 100 / (w + s)
			ans_s = s
			ans_all = w + s
print(ans_all, ans_s)


(A, B, C, D, E, F) = map(int, input().split())
water = 1
sugar = -1
for w_a in range(0, F + 1, 100 * A):
	for w_b in range(0, F - w_a + 1, 100 * B):
		new_w = w_a + w_b
		if new_w == 0:
			continue
		G = min(F - new_w, new_w * E // 100)
		for s_c in range(0, G + 1, C):
			for s_d in range(0, G - s_c + 1, D):
				new_s = s_c + s_d
				if sugar * new_w < new_s * water:
					water = new_w
					sugar = new_s
print(water + sugar, sugar)


(a, b, c, d, e, f) = map(int, input().split())
(a, b) = (a * 100, b * 100)
DP = [-1 for _ in range(f + 3000)]
(DP[a], DP[b]) = (0, 0)
for i in range(f + 1):
	if DP[i] == -1:
		continue
	for j in (a, b):
		if i + j <= f:
			DP[i + j] = DP[i]
	for j in (c, d):
		if i + j <= f and 100 * (DP[i] + j) / (i + j) <= 100 * e / (100 + e):
			DP[i + j] = DP[i] + j
(ans, water) = (0, [a, 0])
for (i, j) in enumerate(DP):
	if i == 0:
		continue
	if ans < 100 * j / i:
		ans = 100 * j / i
		water = [i, j]
print(*water)


(a, b, c, d, e, f) = map(int, input().split())
A = a * 100
B = b * 100
l = []
for i in range(f // A + 1):
	for j in range(f // B + 1):
		if i * A + j * B <= f:
			W = i * A + j * B
			s = W // 100 * e
			r = f - W
			for I in range(s // c + 1):
				for J in range(s // d + 1):
					if I * c + J * d <= s and I * c + J * d + W <= f and (W > 0):
						S = I * c + J * d
						l.append([100 * S / (W + S), W + S, S])
l.sort()
l = l[::-1]
print(l[0][1], l[0][2])


from math import ceil
(A, B, C, D, E, F) = map(int, input().split())
(W, S) = ([], [0])
for ai in range(ceil(F / A)):
	for bi in range(ceil(F / B)):
		w = 100 * A * ai + 100 * B * bi
		if w <= F and 0 < w and (w not in W):
			W.append(w)
for ci in range(ceil(F / C)):
	for di in range(ceil(F / D)):
		s = C * ci + D * di
		if s <= F and 0 < s and (s not in S):
			S.append(s)
(AnsWS, AnsS, r) = (0, 0, -1)
for wi in W:
	for si in S:
		if r < si / wi and si <= E * (wi // 100) and (wi + si <= F):
			(AnsWS, AnsS, r) = (wi + si, si, si / wi)
print(AnsWS, AnsS)


(A, B, C, D, E, F) = map(int, input().split())
water = set()
for a in range(0, F + 1, 100 * A):
	for b in range(0, F + 1, 100 * B):
		if a + b <= F:
			water.add(a + b)
water = sorted(list(water))
suger = set()
for c in range(0, F + 1, C):
	for d in range(0, F + 1, D):
		if c + d <= F:
			suger.add(c + d)
suger = sorted(list(suger))
(kosa, ans1, ans2) = (0, 0, 0)
for w in water:
	for s in suger:
		if w // 100 * E < s or w + s > F:
			break
		if w + s != 0 and kosa <= 100 * s / (w + s):
			kosa = 100 * s / (w + s)
			(ans1, ans2) = (w + s, s)
print(ans1, ans2)


from itertools import product
(A, B, C, D, E, F) = map(int, input().split())
ans = (-1, 0, 0)
for w1 in range(0, F + 1, 100 * A):
	for w2 in range(0, F - w1 + 1, 100 * B):
		w = w1 + w2
		for s1 in range(0, min(F - w + 1, w // 100 * E + 1), C):
			for s2 in range(0, min(F - w - s1 + 1, w // 100 * E - s1 + 1), D):
				s = s1 + s2
				a = w + s
				ans = max(ans, (s / a if a != 0 else -1, a, s))
print(ans[1], ans[2])


(A, B, C, D, E, F) = map(int, input().split())
ans = [100 * A, 0]
for a in range(0, F + 1, A * 100):
	for b in range(0, F + 1, B * 100):
		for c in range(0, F + 1, C):
			for d in range(0, F + 1, D):
				water = a + b
				sugar = c + d
				if water + sugar > F or water == 0 or 100 * sugar > water * E:
					break
				elif ans[1] / (ans[0] + ans[1]) < sugar / (water + sugar):
					ans = [water, sugar]
print(ans[0] + ans[1], ans[1])


(A, B, C, D, E, F) = map(int, input().split())
M = []
S = []
for a in range(1 + F // 100):
	for b in range(1 + F // 100):
		if 100 * (a * A + b * B) <= F:
			M.append(100 * (a * A + b * B))
for c in range(1 + F // C):
	for d in range(1 + F // D):
		if c * C + d * D <= F:
			S.append(c * C + d * D)
ans1 = 0
ans2 = 0
t = -1
for m in M:
	for s in S:
		if m == s == 0:
			pass
		elif m + s <= F and s <= E * m // 100 and (t < 100 * s / (s + m)):
			t = 100 * s / (s + m)
			ans1 = m + s
			ans2 = s
print(ans1, ans2)


(A, B, C, D, E, F) = map(int, input().split())
ans = []
for ai in range(31):
	for bi in range(31):
		for ci in range(101):
			for di in range(101):
				ab = ai * A * 100 + bi * B * 100
				cd = ci * C + di * D
				if ab + cd > F:
					break
				elif ab / 100 * E >= cd:
					ans.append([ab + cd, cd])
print(*sorted(ans, key=lambda x: 100 * x[1] / x[0] if x[0] else 0)[-1])


(a, b, c, d, e, f) = map(int, input().split())
xas = [i * 100 * a for i in range(f // a // 100 + 1)]
xbs = [i * 100 * b for i in range(f // b // 100 + 1)]
xs = {i + j for i in xas for j in xbs if i + j <= f}
yc = [i * c for i in range(f // c + 1)]
yd = [i * d for i in range(f // d + 1)]
ys = {i + j for i in yc for j in yd if i + j <= f}
(x, y, m) = (0, 0, 0)
for i in xas:
	for j in ys:
		if i + j == 0:
			continue
		if j / (i + j) >= m and i + j <= f and (j / (i + j) <= e / (100 + e)):
			x = i
			y = j
			m = y / (x + y)
print(x + y, y)


(A, B, C, D, E, F) = map(int, input().split())
(Swater, sugar, percent) = (100 * A, 0, 0)
for k in range(F // (100 * A) + 1):
	for l in range(F // (100 * B) + 1):
		if k == 0 and l == 0:
			continue
		M = k * A + l * B
		if 100 * M > F:
			continue
		for x in range(M * E // C + 1):
			for y in range(M * E // D + 1):
				S = C * x + D * y
				if 100 * M + S > F:
					continue
				if S > M * E:
					continue
				t = 100 * S / (100 * M + S)
				if t > percent:
					percent = t
					Swater = 100 * M + S
					sugar = S
print(Swater, sugar)


(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])


(a, b, c, d, e, f) = map(int, input().split())
sw = set()
for i in range(30 // a + 1):
	for j in range(30 // b + 1):
		w = a * i + b * j
		if 0 < w * 100 <= f:
			sw |= {w}
ss = set()
for i in range(3000 // c + 1):
	for j in range(3000 // d + 1):
		s = c * i + d * j
		if s <= f:
			ss |= {s}
lt = []
for w in sw:
	for s in ss:
		t = w * 100 + s
		if t <= f and s <= w * e:
			lt += [(-s / w, t, s)]
lt.sort()
print(*lt[0][1:])


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


def main():
	(A, B, C, D, E, F) = map(int, input().split())
	water = set()
	sugar = set()
	for i in range(F // (100 * A) + 1):
		for j in range(F // (100 * B) + 1):
			water_amount = 100 * A * i + 100 * B * j
			if 0 < water_amount and water_amount <= F:
				water.add(water_amount)
	for i in range(F // C + 1):
		for j in range(F // D + 1):
			sugar_amount = C * i + D * j
			if sugar_amount <= F:
				sugar.add(sugar_amount)
	max_c = -1
	max_w = 0
	max_s = 0
	for w in water:
		for s in sugar:
			if w + s <= F:
				if s / w <= E / 100:
					if s * 100 / (w + s) > max_c:
						max_c = s * 100 / (w + s)
						max_w = w
						max_s = s
	print(max_w + max_s, max_s)

def __starting_point():
	main()
__starting_point()


(a, b, c, d, e, f) = map(int, input().split())
w = []
s = []
i = 0
while 100 * a * i <= f:
	j = 0
	while 100 * a * i + 100 * b * j <= f:
		w.append(100 * a * i + 100 * b * j)
		j += 1
	i += 1
i = 0
while c * i <= f:
	j = 0
	while c * i + d * j <= f:
		s.append(c * i + d * j)
		j += 1
	i += 1
mx = -1
mxw = 0
mxs = 0
for wi in w:
	for si in s:
		if wi + si <= f and 100 * si <= wi * e:
			if si > mx * wi:
				mx = si / wi
				mxw = wi
				mxs = si
print(mxs + mxw, mxs)


(a, b, c, d, e, f) = map(int, input().split())
a100 = a * 100
b100 = b * 100
ok = []
for ai in range(31):
	for bi in range(31):
		for ci in range(101):
			for di in range(101):
				ab = ai * a100 + bi * b100
				cd = ci * c + di * d
				if ab + cd > f:
					break
				elif ab / 100 * e >= cd:
					ok.append([ab + cd, cd])
print(*sorted(ok, key=lambda x: 100 * x[1] / x[0] if x[0] else 0)[-1])


(a, b, c, d, e, f) = list(map(int, input().split()))
ma = 0
for aa in range(0, f + 1, a * 100):
	for bb in range(0, f - aa + 1, b * 100):
		water = aa + bb
		if water == 0:
			continue
		smax = min(water // 100 * e, f - water)
		for cc in range(0, smax + 1, c):
			dd = (smax - cc) // d * d
			sugar = cc + dd
			ratio = 100 * sugar / float(water + sugar)
			if ratio >= ma:
				ma = ratio
				ans = [water + sugar, sugar]
print(*ans)


(A, B, C, D, E, F) = map(int, input().split())
x = 1
y = -1
for i in range(0, F + 1, 100 * A):
	for j in range(0, F - i + 1, 100 * B):
		m = min(F - i - j, (i + j) * E // 100)
		if i + j == 0:
			continue
		for k in range(0, m + 1, C):
			for l in range(0, m - k + 1, D):
				if y / x < (k + l) / (i + j):
					x = i + j
					y = k + l
print(x + y, y)


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


(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)


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


(a, b, c, d, e, f) = map(int, input().split())
g = [-1] * 9999
g[a * 100] = 0
g[b * 100] = 0
h = [a * 100, 0]
p = 0
for i in range(1, f + 1):
	if g[i] == -1:
		continue
	if (g[i] + c) / (i - g[i]) <= e * 0.01:
		g[i + c] = max(g[i] + c, g[i + c])
	if (g[i] + d) / (i - g[i]) <= e * 0.01:
		g[i + d] = max(g[i] + d, g[i + d])
	g[i + a * 100] = max(g[i + a * 100], g[i])
	g[i + b * 100] = max(g[i + b * 100], g[i])
	if g[i] / i > p:
		p = g[i] / i
		h = [i, g[i]]
print(*h)


(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 = -1
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)
				ans = (w + s, s)
print(ans[0], ans[1])


(A, B, C, D, E, F) = map(int, input().split())
A *= 100
B *= 100
ans_t = 0
ans_s = 0
for a in range(0, F + 1, A):
	for b in range(0, F - a + 1, B):
		w = a + b
		if w == 0:
			continue
		for c in range(0, F - w + 1, C):
			for d in range(0, F - w - c + 1, D):
				s = c + d
				t = w + s
				if w * E < s * 100:
					break
				if ans_s * t <= s * ans_t:
					ans_t = t
					ans_s = s
print(ans_t, ans_s)


(A, B, C, D, E, F) = map(int, input().split())
a = 0
x = 100 * A
y = 0
for n in range(30):
	for m in range(30):
		if n * 100 * A + m * 100 * B > F:
			continue
		c = (n * A + m * B) * E
		d = F - 100 * (n * A + m * B)
		for k in range(min(c, d) + 1):
			for l in range(min(c, d) + 1):
				if k * C + l * D > (n * A + m * B) * E or n * 100 * A + m * 100 * B + k * C + l * D > F:
					continue
				if x * (k * C + l * D) > y * (n * 100 * A + m * 100 * B + k * C + l * D):
					x = n * 100 * A + m * 100 * B + k * C + l * D
					y = k * C + l * D
					a = y / x
print(x, y)


(A, B, C, D, E, F) = map(int, input().split())
xy = []
for Ai in range(0, F + 1, 100 * A):
	for Bj in range(0, F - Ai + 1, 100 * B):
		x = Ai + Bj
		for Ci in range(0, F - x + 1, C):
			Dj = 0
			y = Ci + Dj
			while x + y <= F:
				xy.append((x, y))
				Dj += D
				y += D
ans = (100 * A, 0)
node = 0
for (x, y) in xy:
	if x == y == 0:
		continue
	if x // 100 * E >= y:
		tmp = 100 * y / (x + y)
		if node < tmp:
			ans = (x + y, y)
			node = tmp
print(*ans)


(a, b, c, d, e, f) = map(int, input().split())
su = [False] * (f + 1)
wa = [False] * (f + 1)
a *= 100
b *= 100
e = 100 * e / (100 + e)
for i in range(f + 1):
	for j in range(f + 1):
		if i * c + j * d <= f:
			su[i * c + j * d] = True
		if i * a + j * b <= f:
			wa[i * a + j * b] = True
ans = -1
(x, y) = (a, 0)
for i in range(1, f + 1):
	for j in range(f + 1):
		if wa[i] and su[j] and (i + j <= f) and (ans <= 100 * j / (i + j) <= e):
			ans = 100 * j / (i + j)
			(x, y) = (i, j)
print(x + y, y)


(A, B, C, D, E, F) = map(int, input().split())
T = list(range(31))
ret = [100 * A, 0]
for a in T:
	for b in T:
		SMax = min((A * a + B * b) * E, F - 100 * (A * a + B * b))
		for d in range(SMax // D + 1):
			c = (SMax - d * D) // C
			S = C * c + D * d
			W = 100 * (A * a + B * b) + S
			if ret[1] * W < ret[0] * S:
				ret = [W, S]
print(*ret)


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


(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)


(A, B, C, D, E, F) = map(int, input().split())
ans = 0
sw = 100 * A
s = 0
for a in range(0, F + 1, 100 * A):
	for b in range(0, F - a + 1, 100 * B):
		if a + b != 0:
			for c in range(0, F - a - b + 1, C):
				for d in range(0, F - a - b - c + 1, D):
					if (c + d) / (a + b) <= E / 100:
						if ans < (c + d) / (a + b + c + d):
							ans = (c + d) / (a + b + c + d)
							sw = a + b + c + d
							s = c + d
print(sw, s)


(a, b, c, d, e, f) = map(int, input().split())
water = []
for i in range(31):
	for j in range(31):
		if a * i + b * j <= f // 100:
			water.append(a * i + b * j)
water.pop(water.index(0))
water = list(set(water))
result = [[0, 0, 0]]
for w in water:
	for i in range(301):
		for j in range(301):
			sugar = c * i + d * j
			if sugar <= w * e and sugar + w * 100 <= f:
				result.append([100 * sugar / (sugar + w * 100), sugar + w * 100, sugar])
result.sort(reverse=True)
print(result[0][1], result[0][2])


(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)


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

def ql():
	ans = (0, A)
	for a in range(0, F, A):
		for b in range(0, F, B):
			for c in range(0, F, C):
				for d in range(0, F, D):
					(wat, sug) = (a + b, c + d)
					if wat + sug > F or 100 * sug > E * wat:
						break
					elif sug * ans[1] > ans[0] * wat:
						ans = (sug, wat)
	return ans
ans = ql()
print('{} {}'.format(sum(ans), ans[0]))


(A, B, C, D, E, F) = map(int, input().split())
M = 0
for i in range(F // 100 // A + 1):
	for j in range((F - 100 * A * i) // 100 // B + 1):
		w = 100 * A * i + 100 * B * j
		if w == 0:
			break
		for k in range((F - w) // C + 1):
			for l in range((F - w - C * k) // D + 1):
				s = C * k + D * l
				if E >= 100 * s / w and 100 * s / w >= M:
					M = 100 * s / w
					X = [w + s, s]
print(X[0], X[1])


(A, B, C, D, E, F) = [int(i) for i in input().split()]
(w, s) = (1, -1)
for a in range(0, F + 1, 100 * A):
	for b in range(0, F - a + 1, 100 * B):
		m = min(F - a - b, (a + b) * E // 100)
		if (a, b) == (0, 0):
			continue
		for c in range(0, m + 1, C):
			for d in range(0, m - c + 1, D):
				if s / w < (c + d) / (a + b):
					(w, s) = (a + b, c + d)
print(w + s, s)


(a, b, c, d, e, f) = map(int, input().split())
maxa = f // (100 * a)
ans = [0, 0, 0]
for i in range(maxa + 1):
	for j in range((f - 100 * a * i) // b + 1):
		v = 100 * a * i + 100 * b * j
		if f < v:
			break
		maxs = min(v * e // 100, f - v)
		for k in range(maxs // d + 1):
			l = (maxs - d * k) // c
			s = c * l + d * k
			if v + s > f:
				continue
			if v / 100 * e < s:
				continue
			if v + s == 0:
				continue
			if ans[0] <= 100 * s / (v + s):
				ans = [100 * s / (v + s), v + s, s]
print(*ans[1:])


(a, b, c, d, e, f) = map(int, input().split())
ans = -1
ans_water = -1
ans_sugar = -1
for ia in range(f // (a * 100) + 2):
	water = 100 * a * ia
	if water > f or water == 0:
		continue
	for ib in range(f // (b * 100) + 2):
		if ib != 0:
			water += 100 * b
		if water > f or water == 0:
			continue
		for ic in range(f // c + 1):
			sugar = c * ic
			if sugar / (water // 100) > e:
				continue
			for id in range(f // d + 1):
				if id != 0:
					sugar += d
				if sugar / (water // 100) > e:
					continue
				if sugar + water > f:
					continue
				if 100 * sugar / (sugar + water) > ans:
					ans = 100 * sugar / (sugar + water)
					ans_water = water
					ans_sugar = sugar
print(ans_sugar + ans_water, ans_sugar)


(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])


(a, b, c, d, e, f) = map(int, input().split())
ans_wat = 0
ans_sug = 0
ans_rate = 0
for i in range(31):
	for j in range(31):
		wat = (i * a + j * b) * 100
		if wat <= f and wat:
			psug = min(f - wat, wat // 100 * e)
			for k in range(psug // c + 1):
				l = (psug - c * k) // d
				sug = k * c + l * d
				rate = 100 * sug / (wat + sug)
				if ans_rate <= rate and rate <= e and (wat + sug <= f):
					ans_wat = wat
					ans_sug = sug
					ans_rate = rate
print(ans_wat + ans_sug, ans_sug)


(a, b, c, d, e, f) = map(int, input().split())
res = -1
ans = [0, 0]
s1 = set()
s2 = set()
for x in range(0, f + 1, 100 * a):
	for y in range(0, f + 1 - x, 100 * b):
		s1.add(x + y)
for x in range(0, f + 1, c):
	for y in range(0, f + 1 - x, d):
		s2.add(x + y)
for x in s1:
	for y in s2:
		if x * e / 100 >= y and 0 < x + y <= f:
			tmp = y / (x + y)
			if tmp > res:
				res = tmp
				ans = [x + y, y]
print(*ans)


from math import ceil
(A, B, C, D, E, F) = map(int, input().split())
(am, bm, cm, dm) = (ceil(31 / A), ceil(31 / B), ceil(F * E / (100 + E) / C) + 1, ceil(F * E / (100 + E) / D) + 1)
temp = []
for a in range(am):
	for b in range(bm):
		for c in range(cm):
			for d in range(dm):
				w = 100 * a * A + 100 * b * B
				s = c * C + d * D
				if w + s > F:
					break
				elif w / 100 * E >= s:
					temp.append([w + s, s])
print(*sorted(temp, key=lambda x: 100 * x[1] / x[0] if x[0] else 0)[-1])


(a, b, c, d, e, f) = map(int, input().split())
t = 0
(ans1, ans2) = (100 * a, 0)
for i in range(31):
	for j in range(31):
		for k in range(101):
			for l in range(101):
				x = 100 * a * i + 100 * b * j
				y = c * k + d * l
				if x == 0:
					break
				if x / 100 * e < y:
					break
				if x + y > f:
					break
				if y / (x + y) > t:
					t = y / (x + y)
					(ans1, ans2) = (x + y, y)
print(ans1, ans2)


(a, b, c, d, e, f) = map(int, input().split())
(ans, cont) = ([0] * 2, 0)
for i in range(f // 100 + 1):
	if i % a == 0 or i % b == 0:
		water = i * 100
		x = min(f - water, i * e)
		suger = 0
		for j in range(x // c + 1):
			s3 = j * c
			suger = max(suger, s3 + (x - s3) // d * d)
		if water != 0:
			if cont <= 100 * suger / (water + suger):
				ans = [water, suger]
				cont = 100 * suger / (water + suger)
print(sum(ans), ans[1])


(a, b, c, d, e, f) = map(int, input().split())
aa = -1
ans = [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 aa < (k + l) / (i + j + k + l):
					aa = (k + l) / (i + j + k + l)
					ans = [i + j + k + l, k + l]
print(ans[0], ans[1])


(a, b, c, d, e, f) = map(int, input().split())
midp = [-1 for i in range(f + 1)]
mizu = []
midp[0] = 0
for i in range(f + 1):
	if midp[i] != -1:
		if i + a * 100 <= f and midp[i + a * 100] != 0:
			midp[i + a * 100] = 0
			mizu.append(i + a * 100)
		if i + b * 100 <= f and midp[i + b * 100] != 0:
			midp[i + b * 100] = 0
			mizu.append(i + b * 100)
ans = 0
cou = [a * 100, 0]
for i in mizu:
	sai = i * e // 100
	sadp = [-1 for f in range(sai + 1)]
	sadp[0] = 0
	maxsa = 0
	for j in range(sai + 1):
		if sadp[j] != -1:
			if j + c <= sai and i + j + c <= f and (sadp[j + c] != 0):
				sadp[j + c] = 0
				maxsa = max(maxsa, j + c)
			if j + d <= sai and i + j + d <= f and (sadp[j + d] != 0):
				sadp[j + d] = 0
				maxsa = max(maxsa, j + d)
	if ans < maxsa / (i + maxsa):
		ans = maxsa / (i + maxsa)
		cou = [i + maxsa, maxsa]
print(*cou)


(a, b, c, d, e, f) = map(int, input().split())
(ans1, ans2) = (0, 0)
(Wat, Salt) = (set(), set())
for i in range(f // (100 * a) + 1):
	for j in range(f // (100 * b) + 1):
		w = a * i * 100 + b * j * 100
		if w <= f:
			Wat.add(w)
for i in range(f // c + 1):
	for j in range(f // d + 1):
		s = c * i + d * j
		if s <= f:
			Salt.add(s)
Wat = list(Wat)
Salt = list(Salt)
for i in Wat:
	for j in Salt:
		if i + j <= f and j * (100 + e) <= e * (i + j) and (j * ans1 >= ans2 * (i + j)):
			(ans1, ans2) = (i + j, j)
print(ans1, ans2)


(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)


import sys
sys.setrecursionlimit(65536)
(a, b, c, d, e, f) = map(int, input().split())

def memoize(f):
	memo = {}

	def g(*args):
		if args not in memo:
			memo[args] = f(*args)
		return memo[args]
	return g

@memoize
def search(w, s):
	if 100 * w + s > f:
		return (-1, w, s)
	if s > e * w or w == 0:
		return max(search(a + w, s), search(b + w, s))
	else:
		return max(search(w, s + c), search(w, s + d), (100 * s / (100 * w + s), w, s))
(_, w, s) = search(0, 0)
print(100 * w + s, s)


(a, b, c, d, e, f) = map(int, input().split())
w = set()
for x in range(0, f + 1, 100 * a):
	for y in range(0, f + 1 - x, 100 * b):
		w.add(x + y)
s = set()
for x in range(0, f + 1, c):
	for y in range(0, f + 1 - x, d):
		s.add(x + y)
ans = -1
sugerwater = 0
suger = 0
for x in w:
	for y in s:
		if 0 < x + y <= f and y <= x * e / 100:
			if ans < y / (x + y):
				ans = y / (x + y)
				sugerwater = x + y
				suger = y
print(sugerwater, suger)


import sys
input = sys.stdin.readline
(A, B, C, D, E, F) = list(map(int, input().split()))
W = set()
for a in range(0, F + 1, A * 100):
	for b in range(0, F + 1, B * 100):
		w = a + b
		if w == 0 or w > F:
			continue
		W.add(w)
S = set()
for c in range(0, F + 1, C):
	for d in range(0, F + 1, D):
		s = c + d
		if s > F:
			continue
		S.add(s)
d_max = -1
ans = None
for w in W:
	for s in S:
		if w * E // 100 < s or w + s > F:
			continue
		d = 100 * s / (w + s)
		if d > d_max:
			d_max = d
			ans = (w + s, s)
print(*ans)


(A, B, C, D, E, F) = (int(T) for T in input().split())
SugM = 0
WatM = 100 * A
for TC in range(0, F + 1):
	for TD in range(0, F + 1):
		Suger = C * TC + D * TD
		RestS = F - Suger
		if RestS >= 0:
			for TA in range(0, RestS // 100 + 1):
				for TB in range(0, RestS // 100 + 1):
					if TA == TB == 0:
						continue
					else:
						Water = TA * A * 100 + TB * B * 100
						RestW = RestS - Water
						if RestW >= 0 and Water >= 100 * Suger / E:
							if SugM / (WatM + SugM) < Suger / (Water + Suger):
								SugM = Suger
								WatM = Water
						else:
							break
		else:
			break
print('{} {}'.format(WatM + SugM, SugM))


(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)


(a, b, c, d, e, f) = map(int, input().split())
w = []
for i in range(f // 100 + 1):
	for j in range(f // 100 + 1):
		x = a * i * 100 + b * j * 100
		if x > 0 and x <= f:
			w.append(x)
w.sort()
s = []
for i in range(f // c + 1):
	for j in range(f // d + 1):
		if c * i + c * i * e / 100 + d * j + d * j * e / 100 <= f:
			s.append(c * i + d * j)
s.sort(reverse=True)
c = -1.0
for i in w:
	for j in s:
		if i + j <= f and j <= i * e / 100:
			if c < 100 * j / (i + j):
				c = 100 * j / (i + j)
				(g, h) = (i + j, j)
print(g, h)


(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)


(a, b, c, d, e, f) = map(int, input().split())
max_s = 0
max_w = a
max_conc = 0
water_s = set()
sugar_s = set()
for i in range(f // a // 100 + 1):
	aa = a * i
	for j in range(f // b // 100 + 1):
		bb = b * j
		if aa + bb <= f // 100:
			water_s.add(aa + bb)
for i in range(f // c + 1):
	cc = c * i
	for j in range(f // d + 1):
		dd = d * j
		if cc + dd <= f:
			sugar_s.add(cc + dd)
for w in water_s:
	for sg in sugar_s:
		if w * 100 + sg <= f and w * e >= sg and (w + sg > 0):
			conc = 100 * sg / (100 * w + sg)
			if max_conc < conc:
				max_conc = conc
				max_w = w
				max_s = sg
print(max_w * 100 + max_s, max_s)


(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])


(a, b, c, d, e, f) = map(int, input().split())
w = [a * i + b * j for i in range(31) for j in range(31) if 0 < a * i + b * j <= f // 100]
m = max(w) * e // min(c, d) + 1
s = [c * i + d * j for i in range(m) for j in range(m) if 0 < c * i + d * j <= max(w) * e]
w = sorted(list(set(w)))
s = sorted(list(set(s)))
mx = 0
res = (min(a, b), 0)
for p in w:
	for q in s:
		if p * 100 + q > f or q / p > e:
			continue
		r = 100 * q / (100 * p + q)
		if mx < r:
			mx = r
			res = (p, q)
(p, q) = res
print(100 * p + q, q)


(A, B, C, D, E, F) = map(int, input().split())
water = []
for i in range(31):
	for j in range(30):
		if (A * i + B * j) * 100 <= F:
			water.append((A * i + B * j) * 100)
sugar = []
for i in range(501):
	for j in range(500):
		if C * i + D * j <= F // 2:
			sugar.append(C * i + D * j)
ans_sum = A * 100
ans_sugar = 0
ans_rate = 0
for i in water:
	for j in sugar:
		if i == 0:
			continue
		if i + j <= F and ans_rate < j / i <= E / 100:
			ans_sum = i + j
			ans_sugar = j
			ans_rate = j / i
print(ans_sum, ans_sugar)


(A, B, C, D, E, F) = map(int, input().split())
(water, sugar) = (-1, -1)
t = 0
for i in range(31):
	for j in range(31):
		for p in range(F // C):
			for q in range(F // D):
				k = i * A + j * B
				pq = p * C + q * D
				if k == 0:
					break
				if k * 100 + pq > F:
					break
				if k * E >= pq:
					if t <= 100 * pq / (100 * k + pq):
						t = 100 * pq / (100 * k + pq)
						(water, sugar) = (100 * k + pq, pq)
print(water, sugar)


(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))


(A, B, C, D, E, F) = list(map(int, input().split()))
answ = 1
anss = 0
for b in range(F // (100 * B) + 1):
	for a in range((F - 100 * B * b) // (100 * A) + 1):
		w = 100 * A * a + 100 * B * b
		if w == 0:
			continue
		smax = min(F - w, w * E // 100)
		s = 0
		for d in range(smax // D + 1):
			c = (smax - d * D) // C
			tmps = c * C + d * D
			s = max(s, tmps)
		if anss * (s + w) <= s * (anss + answ):
			answ = w
			anss = s
print('{} {}'.format(answ + anss, anss))


from itertools import product
(a, b, c, d, e, f) = map(int, input().split())
max_conc = 0
res = [100 * a, 0]
for (w1, w2) in product(range(0, f + 1, 100 * a), range(0, f + 1, 100 * b)):
	if w1 + w2 > f or w1 == w2 == 0:
		continue
	for s1 in range(0, f - w1 - w2 + 1, c):
		s2 = (min(f - w1 - w2, (w1 + w2) // 100 * e) - s1) // d * d
		if s2 < 0:
			continue
		conc = (s1 + s2) / (w1 + w2 + s1 + s2) * 100
		if conc > max_conc:
			max_conc = conc
			res = [w1 + w2 + s1 + s2, s1 + s2]
print(' '.join(map(str, res)))


(a, b, c, d, e, f) = map(int, input().split())
ans = [-1] * 10000
ans[a * 100] = 0
ans[b * 100] = 0
q1 = a * 100
q2 = b * 100
p = 0
fin = [a * 100, 0]
for i in range(1, f + 1):
	if ans[i] == -1:
		continue
	if (ans[i] + c) / (i - ans[i]) <= e * 0.01:
		ans[i + c] = max(ans[i] + c, ans[i + c])
	if (ans[i] + d) / (i - ans[i]) <= e * 0.01:
		ans[i + d] = max(ans[i] + d, ans[i + d])
	ans[i + a * 100] = max(ans[i + a * 100], ans[i])
	ans[i + b * 100] = max(ans[i + b * 100], ans[i])
	if i != 0:
		if ans[i] / i > p:
			p = ans[i] / i
			fin = [i, ans[i]]
print(*fin)


(A, B, C, D, E, F) = map(int, input().split())
a = set()
for i in range(0, F + 1, 100 * A):
	for j in range(0, F + 1 - i, 100 * B):
		a.add(i + j)
b = set()
for i in range(0, F + 1, C):
	for j in range(0, F + 1 - i, D):
		b.add(i + j)
tmp = -1
for aa in a:
	for bb in b:
		if 0 < aa + bb <= F and bb <= aa * E // 100:
			if tmp < bb / (aa + bb):
				ans = (aa + bb, bb)
				tmp = bb / (aa + bb)
print(ans[0], ans[1])


(a, b, c, d, e, f) = map(int, input().split())
(water, suger) = (0, 0)
dense = 0
waters = set()
sugers = set()
for i in range(0, 31, a):
	for j in range(i, 31, b):
		waters.add(j * 100)
for i in range(0, f // 2 + 1, c):
	for j in range(i, f // 2 + 1, d):
		sugers.add(j)
waters = sorted(list(waters))
sugers = sorted(list(sugers))
for w in waters:
	for s in sugers:
		sw = w + s
		if sw > f or s > w // 100 * e or sw == 0:
			continue
		if s / (s + w) >= dense:
			(water, suger) = (sw, s)
			dense = s / (s + w)
print(water, suger)


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)
main()


(a, b, c, d, e, f) = [int(v) for v in input().split()]
water = set()
for i in range(0, f + 1, 100 * a):
	for j in range(0, f - a + 1, 100 * b):
		water.add(i + j)
sugar = set()
for i in range(0, f + 1, c):
	for j in range(0, f - c + 1, d):
		sugar.add(i + j)
max_r = -1
max_sw = -1
max_s = -1
for w in water:
	for s in sugar:
		if 0 < w + s <= f and s <= w * e // 100:
			r = s / (w + s)
			if max_r < r:
				max_r = r
				max_sw = s + w
				max_s = s
print(max_sw, max_s)


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


(a, b, c, d, e, f) = list(map(int, input().split()))
val = 0
lst = [0, 0]
for i in range(31):
	for j in range(31):
		for k in range(101):
			for l in range(101):
				wtr = 100 * i * a + 100 * j * b
				sgr = k * c + l * d
				if wtr == 0 or wtr > f or sgr > f or (wtr + sgr > f):
					break
				elif sgr / (sgr + wtr) <= e / (e + 100) and sgr / (sgr + wtr) > val:
					val = sgr / (sgr + wtr)
					lst[0] = sgr
					lst[1] = sgr + wtr
if lst[0] == 0:
	print(100 * a, 0)
else:
	print(lst[1], lst[0])


(A, B, C, D, E, F) = map(int, input().split())
x_list = []
y_list = []
noudo = []
for i in range(F):
	for j in range(F):
		if C * i + D * j <= F:
			y_list.append(C * i + D * j)
for i in range(F // 100):
	for j in range(F // 100):
		if A * i + B * j <= F // 100:
			x_list.append(100 * (A * i + B * j))
x_list.remove(0)
for x in x_list:
	for y in y_list:
		if x + y <= F and y / (x + y) <= E / (100 + E):
			noudo.append([y / (x + y), x + y, y])
ans = max(noudo)
print(ans[1], ans[2])


(a, b, c, d, e, f) = map(int, input().split())
water = [False] * (f // 100 + 1)
for i in range(0, len(water), a):
	water[i] = True
for i in range(len(water) - b):
	if water[i]:
		water[i + b] = True
sugar = [False] * (f // 100 * e + 1)
for i in range(0, len(sugar), c):
	sugar[i] = True
for i in range(len(sugar) - d):
	if sugar[i]:
		sugar[i + d] = True
deno = a * 100
nume = 0
for i in range(1, len(water)):
	if water[i]:
		j = min([i * e, f - 100 * i])
		while not sugar[j]:
			j -= 1
		i = 100 * i + j
		if nume * i < deno * j:
			deno = i
			nume = j
print(deno, nume)


(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)


(A, B, C, D, E, F) = map(int, input().split(' '))
ans = [0, 0]
r = 0
for i in range(F // A + 1):
	for j in range(F // B + 1):
		if i == 0 and j == 0 or 100 * (A * i + B * j) > F:
			break
		for k in range(F // C + 1):
			for l in range(F // D + 1):
				tmp = 100 * A * i + 100 * B * j + C * k + D * l
				r_tmp = 100 * (C * k + D * l) / tmp
				if tmp > F:
					break
				if r <= r_tmp and 100 * (C * k + D * l) / (100 * (A * i + B * j)) <= E:
					r = r_tmp
					ans = [tmp, C * k + D * l]
print(ans[0], ans[1])


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


(A, B, C, D, E, F) = map(int, input().split())
weight = 100 * A
suger = 0
c = 0
for i in range(F // (100 * A) + 1):
	for j in range(F // (100 * B) + 1):
		for k in range((i * A + j * B) * E // C + 1):
			for l in range((i * A + j * B) * E // D + 1):
				if 100 * (i * A + j * B) + k * C + l * D <= F and k * C + l * D <= (i * A + j * B) * E and (i * i + j * j + k * k + l * l != 0) and ((k * C + l * D) / (100 * (i * A + j * B) + k * C + l * D) > c):
					c = (k * C + l * D) / (100 * (i * A + j * B) + k * C + l * D)
					weight = 100 * (i * A + j * B) + k * C + l * D
					suger = k * C + l * D
print('{} {}'.format(weight, suger))


(A, B, C, D, E, F) = map(int, input().split())
M = 0
Sans = 0
Concmax = -1
for i in range(F // 100 // A + 1):
	WA = i * 100 * A
	for k in range((F - WA) // 100 // B + 1):
		WB = k * 100 * B
		W = WA + WB
		if W <= F:
			for j in range((F - W) // C + 1):
				SC = j * C
				for l in range((F - W - C) // D + 1):
					SD = l * D
					S = SC + SD
					if 0 < W + S <= F and S <= W * E / 100:
						Conc = S / (S + W)
						if Conc > Concmax:
							Concmax = Conc
							Sans = S
							M = S + W
print(M, Sans)


(A, B, C, D, E, F) = map(int, input().split())
rs = []
for a in range(0, F, 100 * A):
	for b in range(0, F, 100 * B):
		x = a + b
		if x == 0 or x > F:
			continue
		for c in range(0, F, C):
			for d in range(0, F, D):
				y = c + d
				if not x + y <= F:
					break
				if not y * 100 <= E * x:
					break
				rs.append((100 * y / (x + y), x + y, y))
(c, z, y) = max(rs)
print(z, y)


(A, B, C, D, E, F) = map(int, input().split())
ans = ['0', '0']
M = -1
for a in range(31):
	if F < a * A * 100:
		break
	for b in range(31 - a):
		if a == 0 and b == 0:
			continue
		W = (a * A + b * B) * 100
		if F < W:
			break
		CD_max = min(E * W // 100, F - W)
		for c in range(CD_max // C + 1):
			d = max(0, (CD_max - c * C) // D)
			CD = c * C + d * D
			con = CD / (W + CD)
			if con > M:
				M = con
				ans = [str(W + CD), str(CD)]
print(' '.join(ans))


(a, b, c, d, e, f) = map(int, input().split())
w = []
for k in range(f // (100 * a) + 1):
	x = a * k
	while x <= f // 100:
		w += [x]
		x += b
s = []
for k in range(f // c + 1):
	x = c * k
	while x <= f:
		s += [x]
		x += d
(p, q) = (a, 0)
for x in w:
	if x == 0:
		continue
	for y in s:
		if 100 * x + y <= f and y / x <= e and (y / x > q / p):
			(p, q) = (x, y)
print(100 * p + q, q)


def maxValue(a, b, v):
	v2 = v
	for i in range(v2, -1, -1):
		for j in range(v2 // a + 1):
			k = i - a * j
			if k % b == 0:
				return i
	return -1
(a, b, c, d, e, f) = list(map(int, input().split()))
waVa = maxValue(a * 100, b * 100, f)
suVa = maxValue(c, d, min(f - waVa, waVa * e // 100))
maxR = 0
anw = waVa
ans = suVa
while 1:
	waVa = maxValue(a * 100, b * 100, waVa - 1)
	suVa = maxValue(c, d, min(f - waVa, waVa * e // 100))
	if waVa == 0:
		break
	if maxR < 100 * suVa / (suVa + waVa):
		maxR = 100 * suVa / (suVa + waVa)
		anw = waVa
		ans = suVa
print(anw + ans, ans)


(a, b, c, d, e, f) = map(int, input().split())
s = set()
for i in range(30 // a + 1):
	for j in range(30 // b + 1):
		if 0 < (a * i + b * j) * 100 <= f:
			s = s | {a * i + b * j}
s2 = set()
for i in range(3000 // c + 1):
	for j in range(3000 // d + 1):
		if c * i + d * j <= f:
			s2 = s2 | {c * i + d * j}
ans = []
for i in s:
	for j in s2:
		if i * 100 + j <= f and j <= i * e:
			ans.append([j / i * -1, i * 100 + j, j])
ans.sort()
print(ans[0][1], ans[0][2])


(A, B, C, D, E, F) = map(int, input().split())
best_water = 0
best_salt = 0
best_rate = 0
for i in range(30 // A + 1):
	for j in range(30 // B + 1):
		water = (i * A + j * B) * 100
		if water <= F and water:
			max_salt = min(F - (i * A + j * B) * 100, (i * A + j * B) * E)
			for k in range(max_salt // C + 1):
				l = (max_salt - C * k) // D
				salt = k * C + l * D
				rate = 100 * salt / (water + salt)
				if rate >= best_rate and rate <= E and (water + salt <= F):
					best_rate = rate
					best_salt = salt
					best_water = water
print(best_water + best_salt, best_salt)


(A, B, C, D, E, F) = map(int, input().split())
solve = E / (100 + E)
ans = [0, 0, 0]
for i in range(int(F // 100 // A) + 1):
	for j in range(int((F - A * 100 * i) // 100 // B) + 1):
		for k in range(int((F - A * 100 * i - B * 100 * j) // C) + 1):
			for l in range(int((F - A * 100 * i - B * 100 * j - C * k) // D) + 1):
				if i != 0 or j != 0:
					can = (C * k + D * l) / (A * 100 * i + B * 100 * j + C * k + D * l)
					if solve >= can >= ans[0]:
						(ans[0], ans[1], ans[2]) = (can, A * 100 * i + B * 100 * j + C * k + D * l, C * k + D * l)
print(ans[1], ans[2])


(a, b, c, d, e, f) = map(int, input().split())
x = set()
y = set()
m = f // (100 * a)
for i in range(m + 1):
	for j in range(f // (100 * b) + 1):
		x1 = i * 100 * a + j * 100 * b
		if x1 <= f:
			x.add(x1)
m = int(f * (e / 100))
for i in range(0, m + 1, c):
	for j in range(0, m - i + 1, d):
		y.add(i + j)
x.remove(0)
z = [-1]
ans = []
for i in x:
	for j in y:
		if i + j <= f and j * 100 / (i + j) <= e * 100 / (100 + e):
			if j * 100 / (i + j) > max(z):
				z.append(j * 100 / (i + j))
				ans.append([i + j, j])
print(ans[-1][0], ans[-1][1])


(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])


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


(a, b, c, d, e, f) = map(int, input().split())
W = set()
S = set()
sa = 0
wsa = a * 100
for i in range(0, f + a * 100, a * 100):
	for j in range(0, f + b * 100, b * 100):
		w = i + j
		if w <= f:
			W.add(w)
		else:
			break
for i in range(0, f // 2 + c, c):
	for j in range(0, f // 2 + d, d):
		s = i + j
		if s <= f // 2:
			S.add(s)
		else:
			break
S.remove(0)
for i in W:
	for j in S:
		if e / (100 + e) >= j / (i + j) > sa / wsa and i + j <= f:
			(sa, wsa) = (j, i + j)
print(wsa, sa)


(A, B, C, D, E, F) = map(int, input().split())
maxim = -1
ans = [0, 0]
for i in range(F // 100 // A + 2):
	for j in range(F // 100 // B + 2):
		if A * 100 * i + B * 100 * j >= F:
			break
		for k in range(F // C + 2):
			if A * 100 * i + B * 100 * j + C * k >= F:
				break
			for l in range(F // D + 2):
				s = D * l + C * k
				w = A * 100 * i + B * 100 * j
				if s + w <= F:
					if w // 100 * E >= s:
						if s + w != 0:
							if maxim < 100 * s / (s + w):
								maxim = 100 * s / (s + w)
								ans = [w + s, s]
print(*ans)


import sys
input = sys.stdin.readline

def main():
	(A, B, C, D, E, F) = list(map(int, input().split()))
	max_concentration = 0
	ans = (100 * A, 0)
	for a in range(0, F + 1, 100 * A):
		for b in range(0, F - a + 1, 100 * B):
			water = a + b
			if water == 0:
				break
			for c in range(0, F - water + 1, C):
				for d in range(0, F - water - c + 1, D):
					sugar = c + d
					if sugar > water // 100 * E:
						break
					concentration = 100 * sugar / (water + sugar)
					if concentration > max_concentration:
						max_concentration = concentration
						ans = (water + sugar, sugar)
	print(' '.join(map(str, ans)))

def __starting_point():
	main()
__starting_point()


(a, b, c, d, e, f) = map(int, input().split())
tmp = {}
for i in range(31):
	for j in range(31):
		for k in range(101):
			for l in range(101):
				w = 100 * a * i + 100 * b * j
				s = c * k + d * l
				if w == 0:
					break
				if w + s > f:
					break
				elif w / 100 * e >= s:
					density = 100 * s / (w + s)
					tmp[w, s] = density
mxv = max(tmp, key=tmp.get)
print(mxv[0] + mxv[1], mxv[1])


(a, b, c, d, e, f) = map(int, input().split())
(ans, index) = (0, [a * 100, 0])
base = 100 * e / (100 + e)
for i in range(31):
	for j in range(31):
		for k in range(101):
			for l in range(101):
				w = i * 100 * a + j * 100 * b
				s = c * k + d * l
				if w == 0:
					continue
				if w + s > f:
					break
				den = s * 100 / (w + s)
				if den <= base and ans < den:
					ans = den
					index = [w + s, s]
print(*index)


(A, B, C, D, E, F) = map(int, input().split())
ans = [100, -1]
e = E / (100 + E)
W = [a + b for a in range(0, F + 1, 100 * A) for b in range(0, F + 1, 100 * B) if a != 0 or b != 0]
for w in W:
	for c in range(0, F - w + 1, C):
		for d in range(0, F - w - c + 1, D):
			s = c + d
			if w + s > F or s / (w + s) > e:
				break
			elif ans[1] / ans[0] < s / (w + s) <= e:
				ans = [w + s, s]
print(ans[0], ans[1])


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])


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

def check(goal, ac, bd):
	flag = 0
	for x in range(int(goal // ac) + 1):
		if (goal - ac * x) % bd == 0:
			flag = 1
			break
	return flag
anss = []
for w in range(100, f + 1, 100):
	for s in range(1, f - w + 1):
		if check(w, 100 * a, 100 * b) and check(s, c, d) and (s <= w * e / 100):
			conc = 100 * s / (w + s)
			anss.append([conc, w, s])
anss.sort(reverse=1)
(w, s) = (anss[0][1], anss[0][2]) if anss else (100 * a, 0)
print(w + s, s)


(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 * B * j <= F:
			water |= {100 * A * i + 100 * B * j}
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}
water -= set({0})
max_ = 0
for w in water:
	for s in sugar:
		if w + s <= F and s * (100 + E) <= E * (w + s) and (max_ * (w + s) <= s):
			max_ = s / (w + s)
			ans = [w + s, s]
print(ans[0], ans[1])


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


(A, B, C, D, E, F) = map(int, input().split())
mxc = 0
ans = (min(100 * A, 100 * B), 0)
for i in range(31):
	for j in range(31):
		for k in range(101):
			for l in range(101):
				w = 100 * A * i + 100 * B * j
				s = C * k + D * l
				if s > E * w / 100 or w + s > F or w == 0:
					break
				if 100 * s / (s + w) > mxc:
					mxc = 100 * s / (s + w)
					ans = (s + w, s)
print(' '.join(map(str, ans)))


(a, b, c, d, e, f) = map(int, input().split())
youeki = 0
yousitu = 0
noudo = 0
n_a = int(f / (100 * a))
for i in range(2 + n_a):
	for j in range(2 + int((f - 100 * i * a) / (100 * b))):
		for k in range(2 + int((f - 100 * i * a - 100 * j * b) / c)):
			for l in range(2 + int((f - 100 * i * a - 100 * j * b - k * c) / d)):
				S = 100.0 * a * i + 100.0 * b * j + c * k + d * l
				T = c * k + d * l
				if S != 0:
					L = 100.0 * T / S
					if S <= f and L <= 100 * e / (100 + e) and (L >= noudo):
						noudo = L
						youeki = S
						yousitu = T
print(int(youeki), int(yousitu))


(a, b, c, d, e, f) = map(int, input().split())
w = []
for i in range(f // 100 // a + 1):
	for j in range(f // 100 // b + 1):
		if (i * a + j * b) * 100 <= f:
			w.append(i * 100 * a + j * 100 * b)
w = set(w)
w.remove(0)
s = []
for i in range(e * f // 100 // c + 1):
	for j in range(e * f // 100 // d + 1):
		if i * c + j * d <= e * f // 100:
			s.append(i * c + j * d)
s = sorted(set(s))
ans = []
for i in w:
	for j in s:
		if i != 0 and j <= e * i // 100 and (i + j <= f):
			ans.append([j / (i + j), j + i, j])
ans.sort()
print(ans[-1][1], ans[-1][2])


(a, b, c, d, e, f) = map(int, input().split())
A = sorted(list(set([a * i + b * j for j in range(f // (100 * b) + 1) for i in range(f // (100 * a) + 1) if 100 * (a * i + b * j) <= f])))
B = sorted(list(set([c * i + d * j for j in range(f // d + 1) for i in range(f // c + 1) if c * i + d * j <= f])))
r = w = s = 0
for x in A[1:]:
	for y in B:
		if 100 * x + y <= f and y <= x * e and (r <= y / (100 * x + y)):
			r = y / (100 * x + y)
			w = 100 * x + y
			s = y
print(w, s)


(a, b, c, d, e, f) = map(int, input().split(' '))
w = 0
s = 0
ratio = 0
for i in range(f // (b * 100) + 1):
	for j in range((f - i * b * 100) // (a * 100) + 1):
		if i == 0 and j == 0:
			continue
		smax = min(f - (j * a + i * b) * 100, (j * a + i * b) * e)
		sm = 0
		for k in range(smax // d + 1):
			sm = max(sm, k * d + c * ((smax - k * d) // c))
		if ratio <= sm / ((j * a + i * b) * 100 + sm):
			ratio = sm / ((j * a + i * b) * 100 + sm)
			w = (j * a + i * b) * 100
			s = sm
print('%i %i' % (w + s, s))


import sys
read = sys.stdin.read
readline = sys.stdin.readline
(a, b, c, d, e, f) = map(int, readline().split())

def searints(m, n, l):
	mask = (1 << l + 1) - 1
	s = sum([1 << n * i for i in range(1, l // n + 1)]) & mask
	for i in range(1, l // m + 1):
		s = (s + 1 << m * i | s) & mask
	return [x for x in range(0, l + 1) if s + 1 >> x & 1 == 1]
w = searints(100 * a, 100 * b, f)
s = searints(c, d, f)
candidates = [(100 * y / (x + y), x + y, y) for x in w for y in s if e * x >= 100 * y and x * y > 0 and (x + y <= f)]
if candidates:
	print(*max(candidates)[1:])
else:
	print(100 * a, 0)


(a, b, c, d, e, f) = map(int, input().split())
(ans, con) = ([0] * 2, 0)
for i in range(f // 100 + 1):
	if i % a == 0 or i % b == 0:
		w = i * 100
		x = min(f - w, i * e)
		s = 0
		for j in range(x // c + 1):
			s3 = j * c
			s = max(s, s3 + (x - s3) // d * d)
		if w != 0:
			if con <= 100 * s / (w + s):
				ans = [w, s]
				con = 100 * s / (w + s)
print(sum(ans), ans[1])


(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])


(A, B, C, D, E, F) = map(int, input().split())
ws = set()
for a in range(0, F + 1, 100 * A):
	for b in range(0, F + 1, 100 * B):
		if a + b > F:
			break
		ws.add(a + b)
ws.remove(0)
ss = set()
for c in range(0, F + 1, C):
	for d in range(0, F + 1, D):
		if c + d > F:
			break
		ss.add(c + d)
best_s = -1
best_w = 1
for w in ws:
	for s in ss:
		if w + s > F:
			continue
		if E * w < s * 100:
			continue
		if best_s * (s + w) < s * (best_s + best_w):
			best_s = s
			best_w = w
print(best_s + best_w, best_s)


(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))


import math
(A, B, C, D, E, F) = map(int, input().split())
water = []
for i in range(math.floor(F / (100 * A)) + 1):
	M = 100 * A * i
	while M <= F:
		if M not in water and M != 0:
			water.append(M)
		M += 100 * B

def max_dens(w):
	max_s = min(F - w, w * E / 100)
	max_d = 0
	for i in range(math.floor(max_s / D) + 1):
		sugar = math.floor((max_s - i * D) / C) * C + i * D
		max_d = max(max_d, sugar)
	return max_d
den = [max_dens(x) / x for x in water]
index = den.index(max(den))
print(water[index] + max_dens(water[index]), max_dens(water[index]))


from decimal import Decimal as D
(mi1, mi2, sa1, sa2, houwa, lim) = map(int, input().split())
slim = houwa * lim // (100 + houwa)
ws = set((mi1 * i + mi2 * j for i in range(lim // (100 * mi1) + 2) for j in range(lim // (100 * mi2) + 2) if 100 * (mi1 * i + mi2 * j) <= lim))
ss = set((sa1 * i + sa2 * j for i in range(slim // sa1 + 2) for j in range(slim // sa2 + 2) if sa1 * i + sa2 * j <= slim))
ans = D('0')
(iw, isa) = (mi1, 0)
for s in ss:
	for w in ws:
		if s > houwa * w or w == 0:
			continue
		if ans < D(str(10000 * s)) / D(str(s + 100 * w)) and s + 100 * w <= lim:
			ans = D(str(10000 * s)) / D(str(s + 100 * w))
			(isa, iw) = (s, w)
print(100 * iw + isa, isa)


def i1():
	return int(input())

def i2():
	return [int(i) for i in input().split()]
[a, b, c, d, e, f] = i2()
w = []
s = []
for i in range(f + 1):
	for j in range(f + 1):
		t = (a * i + b * j) * 100
		tt = c * i + d * j
		if t <= f:
			w.append(t)
		if tt <= f:
			s.append(tt)
a = 0
g = []
for i in w:
	for j in s:
		if 0 < i + j <= f and j <= i * e / 100:
			g.append([j * 100 / (i + j), i + j, j])
g.sort()
print(g[-1][1], g[-1][2])


(A, B, C, D, E, F) = map(int, input().split())
memo = []
for a in range(31):
	for b in range(31):
		for c in range(101):
			for d in range(101):
				w = 100 * A * a + 100 * B * b
				s = C * c + D * d
				if w + s > F:
					break
				elif w / 100 * E >= s:
					memo.append([w + s, s])
print(*sorted(memo, key=lambda x: 100 * x[1] / x[0] if x[0] else 0)[-1])


(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)


(A, B, C, D, E, F) = map(int, input().split())
concentration = 0
ans = [A * 100, 0]
water = []
for a in range(F // (A * 100) + 1):
	for b in range((F - a * A * 100) // (B * 100) + 1):
		water.append((a * A + b * B) * 100)
water = sorted(list(set(water)))
sugar = []
for c in range(F // C + 1):
	for d in range((F - c * C) // D + 1):
		sugar.append(c * C + d * D)
sugar = sorted(list(set(sugar)))
for wa in water:
	for su in sugar:
		if wa + su <= F:
			if su <= wa / 100 * E:
				if wa != 0:
					if concentration < su / (su + wa):
						concentration = su / (su + wa)
						ans = [su + wa, su]
print(' '.join(map(str, ans)))


(A, B, C, D, E, F) = map(int, input().split())
best = -1.0
ws = sg = 0
for a in range(0, F + 1, 100 * A):
	for b in range(0, F - a + 1, 100 * B):
		w = a + b
		m = min(F - w, w * E // 100)
		if w == 0:
			continue
		for c in range(0, m + 1, C):
			for d in range(0, m - c + 1, D):
				s = c + d
				if best < s / (w + s):
					best = s / (w + s)
					ws = w + s
					sg = s
print(ws, sg)


(A, B, C, D, E, F) = map(int, input().split())
items = []
water = list(set([100 * (A * w + B * x) for w in range(16) for x in range(16) if A * w + B * x <= 30]))
water.sort()
for w in water:
	for x in range(1501):
		c = C * x
		i = (F - w - c) // D
		for y in reversed(range(i + 1)):
			d = D * y
			if 0 < w + c + d <= F and w * E >= 100 * (c + d):
				items.append((100 * (c + d) / (w + c + d), w + c + d, c + d))
				break
items.sort(reverse=True)
print(items[0][1], items[0][2])


import bisect, heapq
(a, b, c, d, e, f) = map(int, input().split())
w = set()
temp = [a * i for i in range((30 - 1) // a + 2)]
for i in temp:
	while i not in w and i <= 30:
		w.add(i)
		i += b
w = list(w)
w.remove(0)
w.sort()
s = set()
temp = [c * i for i in range((3000 - 1) // c + 2)]
for i in temp:
	while i not in s and i <= 3000:
		s.add(i)
		i += d
s = list(s)
s.sort()
queue = []
heapq.heapify(queue)
for i in w:
	if i * 100 > f:
		continue
	num = bisect.bisect(s, i * e)
	for j in range(num - 1, -1, -1):
		if i * 100 + s[j] > f:
			continue
		heapq.heappush(queue, [-s[j] / i, 100 * i + s[j], s[j]])
		break
print(queue[0][1], queue[0][2])


(A, B, C, D, E, F) = map(int, input().split())
L = []
for a in range(31):
	for b in range(31):
		k = A * a + B * b
		if 0 < 100 * k <= F:
			L.append(k)
L.sort()
su = 0
for (i, l) in enumerate(L):
	limit = min(F - 100 * l, E * l)
	wd = 100 * l
	if i == 0:
		w = wd
	for c in range(3000):
		if C * c > limit:
			break
		d = (limit - C * c) // D
		p = C * c + D * d
		if p * w > wd * su:
			w = wd
			su = p
print(w + su, su)


(A, B, C, D, E, F) = map(int, input().split())
Ws = set()
for a in range(0, F + 1, 100 * A):
	for b in range(0, F + 1 - a, 100 * B):
		Ws.add(a + b)
Ss = set()
for c in range(0, F + 1, C):
	for d in range(0, F + 1 - c, D):
		Ss.add(c + d)
ans = set()
for w in Ws:
	for s in Ss:
		if 0 < w + s <= F and s <= w // 100 * E:
			ans.add((s / (w + s), w, s))
ans = sorted(ans, reverse=True)
print(ans[0][1] + ans[0][2], ans[0][2])


(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)


from math import ceil
(A, B, C, D, E, F) = map(int, input().split())
(W, S) = ([], [0])
for i in range(ceil(F / A)):
	for j in range(ceil(F / B)):
		w = 100 * A * i + 100 * B * j
		if w <= F and 0 < w and (w not in W):
			W.append(w)
for i in range(ceil(F / C)):
	for j in range(ceil(F / D)):
		s = C * i + D * j
		if s <= F and 0 < s and (s not in S):
			S.append(s)
(Ans1, Ans2, r) = (0, 0, -1)
for wi in W:
	for si in S:
		if r < si / wi and si <= E * (wi // 100) and (wi + si <= F):
			(Ans1, Ans2, r) = (wi + si, si, si / wi)
print(Ans1, Ans2)


(a, b, c, d, e, f) = map(int, input().split())
w = set()
for x in range(0, f + 1, 100 * a):
	for y in range(0, f + 1 - x, 100 * b):
		w.add(x + y)
s = set()
for x in range(0, f + 1, c):
	for y in range(0, f + 1 - x, d):
		s.add(x + y)
max = -1
total = 0
sugar = 0
for x in w:
	for y in s:
		if 0 < x + y <= f and y <= x * e // 100:
			if max < y / (x + y):
				total = x + y
				sugar = y
				max = y / (x + y)
print(total, sugar)


(A, B, C, D, E, F) = map(int, input().split())
x = set()
y = set()
for i in range(F // (100 * A) + 1):
	for j in range((F - 100 * A * i) // (100 * B) + 1):
		if i + j == 0:
			continue
		x.add(A * i * 100 + B * j * 100)
for i in range(F // C + 1):
	for j in range((F - C * i) // D + 1):
		y.add(C * i + D * j)
ret_w = 1
ret_s = -1
for w in x:
	for s in y:
		if w + s <= F and w * E / 100 >= s and (s / (w + s) >= ret_s / ret_w):
			ret_s = s
			ret_w = w + s
print(ret_w, ret_s)


inf = 10 ** 8
(a, b, c, d, e, f) = map(int, input().split())
(a, b) = (100 * a, 100 * b)
DP = [inf] * (f + max(a, b) + 1)
(DP[a], DP[b]) = (0, 0)
for i in range(f + 1):
	if DP[i] != inf:
		DP[i + a] = DP[i]
		DP[i + b] = DP[i]
		for j in (c, d):
			if 100 * (DP[i] + j) / (i + j) <= 100 * e / (100 + e):
				DP[i + j] = max(DP[i], DP[i] + j)
(ans, index) = (0, [a, 0])
for i in range(f + 1):
	if DP[i] != inf:
		if ans < 100 * DP[i] / i:
			ans = 100 * DP[i] / i
			index = [i, DP[i]]
print(*index)


(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))


(a, b, c, d, e, f) = map(int, input().split())
x = []
for i in range(int(f / 100 + 0.9)):
	for j in range(int(f / 100 + 0.9)):
		if 100 * a * i + 100 * b * j <= f:
			x.append(100 * a * i + 100 * b * j)
y = []
for i in range(int(f / c + 0.9)):
	for j in range(int(f / d + 0.9)):
		if c * i + d * j <= f:
			y.append(c * i + d * j)
p = e / (100 + e)
maxp = 0
mj = 0
mi = 0
for i in x:
	for j in y:
		if i + j <= f and i + j > 0 and (j / (i + j) <= p):
			if j / (i + j) >= maxp:
				mj = j
				mi = i
				maxp = j / (i + j)
print(str(mj + mi) + ' ' + str(mj))


(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)


(A, B, C, D, E, F) = map(int, input().split())
ans1 = A
ans2 = 0
for i in range(A, F // 100 + 1):
	if any(((i - A * j) % B == 0 for j in range(i // A + 1))):
		x = min(E * i, F - i * 100)
		e = max([C * j + (x - C * j) // D * D for j in range(x // C + 1)])
		if e * ans1 > ans2 * i:
			ans1 = i
			ans2 = e
print(ans1 * 100 + ans2, ans2)


(a, b, c, d, e, f) = map(int, input().split())
water = []
for i in range(31):
	for j in range(31):
		if (a * i + b * j) * 100 <= f:
			water.append(a * i + b * j)
water = list(set(water))
result = [[0, a * 100, 0]]
for i in water:
	for x in range(301):
		for y in range(301):
			if i > 0 and c * x + d * y > 0 and (c * x + d * y <= i * e) and (c * x + d * y + 100 * i <= f):
				result.append([100 * (c * x + d * y) / (c * x + d * y + 100 * i), c * x + d * y + 100 * i, c * x + d * y])
result.sort(reverse=True)
print(result[0][1], result[0][2])


(A, B, C, D, E, F) = map(int, input().split())
w = set()
s = set()
for i in range(31):
	for j in range(16):
		if 100 * (A * i + B * j) <= F:
			w.add(100 * (A * i + B * j))
for i in range(1501):
	for j in range(751):
		if C * i + D * j <= F / 2:
			s.add(C * i + D * j)
w = list(w)
w.sort()
del w[0]
s = list(s)
s.sort()
M = -1
for i in w:
	for j in range(len(s) - 1, -1, -1):
		if s[j] * 100 <= E * i:
			if s[j] > M * i and i + s[j] <= F:
				(W, S) = (i, s[j])
				M = s[j] / i
print(W + S, S)


(a, b, c, d, e, f) = map(int, input().split())
ans = []
for aa in range(31):
	for bb in range(31):
		w = 100 * (aa * a + bb * b)
		if w > f:
			break
		n = min(f - w, e * (aa * a + bb * b))
		for cc in range(3001):
			s = cc * c
			if s > n:
				break
			nn = n - s
			ss = d * (nn // d)
			su = s + ss
			wa = w
			if wa + su == 0:
				continue
			ans.append([100 * su / (wa + su), wa, su])
ans.sort(reverse=1)
(_, w, s) = ans[0]
print(w + s, s)


(a, b, c, d, e, f) = map(int, input().split())
ans = [100 * min(a, b), 0]
for i in range(31):
	for j in range(31):
		if i == 0 and j == 0:
			break
		l1 = f - (100 * a * i + 100 * b * j)
		l2 = (a * i + b * j) * e
		l = min(l1, l2)
		(cc, dc) = (0, 0)
		for k in range(l // c + 1):
			tc = k
			td = (l - c * tc) // d
			if l - (c * tc + d * td) < l - (c * cc + d * dc):
				(cc, dc) = (tc, td)
		wa = 100 * a * i + 100 * b * j
		sa = c * cc + d * dc
		tmp = [wa + sa, sa]
		if wa + sa > f or sa > e * (a * i + b * j):
			break
		if tmp[1] / tmp[0] > ans[1] / ans[0]:
			ans = tmp
print(ans[0], ans[1])


(a, b, c, d, e, f) = map(int, input().split())
maxm = 100 * a
maxs = 0
water = set()
suger = set()
for i in range(31):
	for j in range(31):
		if i * a * 100 + j * b * 100 <= f and i * a * 100 + j * b * 100 > 0:
			water.add(i * a * 100 + j * b * 100)
for i in range(f + 1):
	for j in range(f + 1):
		suger.add(c * i + d * j)
for i in water:
	for j in suger:
		if i * e // 100 >= j and i + j <= f:
			tmpm = i + j
			tmps = j
			if tmps * maxm > maxs * tmpm:
				maxm = tmpm
				maxs = tmps
print(maxm, maxs)


(a, b, c, d, e, f) = map(int, input().split())
t = 100
for i in range(0, f + 1, a * 100):
	for j in range(0, f - i + 1, b * 100):
		k = i + j
		if k == 0:
			continue
		s = min(f - i - j, (i + j) * e // 100)
		for ii in range(0, s + 1, c):
			for jj in range(0, s - ii + 1, d):
				if t > e - (ii + jj) * 100 / (i + j):
					t = e - (ii + jj) * 100 / (i + j)
					(x, y) = (ii + jj + i + j, ii + jj)
print(str(x) + ' ' + str(y))


(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])


(A, B, C, D, E, F) = map(int, input().split())
W = sorted(list({a * 100 * A + b * 100 * B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a * 100 * A + b * 100 * B <= F}))
S = [max([c * C + d * D for c in range(int(E * w / 100 / C) + 1) for d in range(int(E * w / 100 / D) + 1) if (c * C + d * D) * 100 <= E * w and c * C + d * D + w <= F]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i: W[i] / (W[i] + S[i]) if W[i] > 0 else 1)[0]
print(100 * A if W[I] == 0 else W[I] + S[I], S[I])


(A, B, C, D, E, F) = map(int, input().split(' '))
water = set()
for a in range(0, F, 100 * A):
	for b in range(0, F, 100 * B):
		if a + b <= F:
			water.add(a + b)
		else:
			break
sugars = set()
for c in range(0, F, C):
	for d in range(0, F, D):
		if c + d <= F:
			sugars.add(c + d)
		else:
			break
density = 0
sugar = 0
content = 100 * A
for x in water:
	for y in sugars:
		if x + y != 0 and x + y <= F and (E * x >= 100 * y) and (density < y / (x + y)):
			density = y / (x + y)
			sugar = y
			content = x + y
print(content, sugar)


(A, B, C, D, E, F) = map(int, input().split())
conc = -1
ans = (0, 0)
for a in range(0, F + 1, 100 * A):
	for b in range(0, F - a + 1, 100 * B):
		w = a + b
		if w == 0:
			continue
		for c in range(0, min(w * E // 100, F - w) + 1, C):
			d = min(w * E // 100 - c, F - w - c) // D * D
			s = c + d
			if conc < s / (w + s):
				conc = s / (w + s)
				ans = (w + s, s)
print(*ans)


(a, b, c, d, e, f) = map(int, input().split())
a *= 100
b *= 100
res = chk = 0
ans = []
for i in range(16):
	for j in range(16):
		for k in range(1501):
			w = i * a + j * b
			s = k * c
			o = w // 100 * e
			if w == 0:
				pass
			elif w + s > f or s > o:
				break
			else:
				s += min(f - w - s, o - s) // d * d
				if len(ans) == 0:
					ans = [s / (w + s), w + s, s]
				elif s / (w + s) > ans[0]:
					ans = [s / (w + s), w + s, s]
print(ans[1], ans[2])


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

def makeSet(a, b):
	list = []
	for i in range(int(F / a + 2)):
		for j in range(int(F / b + 2)):
			tmp = i * a + j * b
			if tmp > F:
				break
			list.append(tmp)
	return set(list)
W = makeSet(A * 100, B * 100)
S = makeSet(C, D)

def isOK(a, b):
	return b * (100 + E) <= E * (a + b) and a + b <= F
ma = F
mb = 0

def chmax(a, b):
	if b * (ma + mb) >= mb * (a + b):
		return (a, b)
	return (ma, mb)
for w in W:
	for s in S:
		if isOK(w, s):
			(ma, mb) = chmax(w, s)
print(ma + mb, mb)


(a, b, c, d, e, f) = map(int, input().split())
w = set()
for i in range(0, f, 100 * a):
	for j in range(0, f, 100 * b):
		if i + j <= f:
			w.add(i + j)
		else:
			break
s = set()
for i in range(0, f, c):
	for j in range(0, f, d):
		if i + j <= f:
			s.add(i + j)
		else:
			break
n = 100 * a
m = 0
l = 0
for x in w:
	for t in s:
		if x + t != 0 and x + t <= f and (100 * t <= e * x) and (t / (x + t) > l):
			n = x + t
			m = t
			l = t / (x + t)
print(n, m)


(a, b, c, d, e, f) = map(int, input().split())
l = []
for i in range(0, f // (100 * a) + 1):
	for j in range(0, f // (100 * b) + 1):
		if 100 * a * i + 100 * b * j > f:
			pass
		else:
			l.append(100 * a * i + 100 * b * j)
l1 = []
del l[0]
max1 = 0
g = 0
h = 0
for i in l:
	l2 = []
	m = min(f - i, i // 100 * e)
	max2 = 0
	for j in range(0, m // c + 1):
		for k in range(0, m // d + 1):
			if j * c + k * d <= m and j * c + k * d > max2:
				max2 = j * c + k * d
	if max1 <= 100 * max2 / (i + max2):
		g = i
		h = max2
		max1 = 100 * max2 / (i + max2)
print(g + h, h)


(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])


(a, b, c, d, e, f) = map(int, input().split())
xset = set()
yset = set()
for i in range(31):
	for j in range(16):
		if (a * i + b * j) * 100 <= f:
			xset.add((a * i + b * j) * 100)
xset.remove(0)
for i in range(f // c + 1):
	for j in range(f // d + 1):
		if c * i + c * j <= f:
			yset.add(c * i + d * j)
ll = []
maxconc = 0
maxsolution = 100 * a
maxsolute = 0
for i in xset:
	for j in yset:
		if i + j <= f and i >= 100 * j / e and (100 * j / (i + j) > maxconc):
			maxconc = 100 * j / (i + j)
			maxsolution = i + j
			maxsolute = j
print(str(maxsolution) + ' ' + str(maxsolute))


(A, B, C, D, E, F) = map(int, input().strip().split())
X = set([])
Y = set([])
ans = (-1, 0, 0)
for w1 in range(0, F + 1, 100 * A):
	for w2 in range(0, F - w1 + 1, 100 * B):
		w = w1 + w2
		for s1 in range(0, min(F - w + 1, w // 100 * E + 1), C):
			for s2 in range(0, min(F - w - s1 + 1, w // 100 * E - s1 + 1), D):
				s = s1 + s2
				a = w + s
				ans = max(ans, (s / a if a != 0 else -1, a, s))
print(ans[1], ans[2])


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


(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)


(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)


(A, B, C, D, E, F) = map(int, input().split())
(A, B) = (A * 100, B * 100)
water = []
for i in range(F // A + 1):
	for j in range(F // B + 1):
		if A * i + B * j <= F and (not (i == 0 and j == 0)):
			water.append(A * i + B * j)
water = list(set(water))
ans = [water[0], 0]
mconc = 0
sugar = []
for x in water:
	sugar.append(min(F - x, x * E // 100))
for (w, s) in zip(water, sugar):
	for i in range(s // C + 1):
		j = (s - C * i) // D
		cap = C * i + D * j
		if cap / (w + cap) * 100 > mconc:
			mconc = cap / (w + cap) * 100
			ans = [w + cap, cap]
print(*ans)


from itertools import product
(a, b, c, d, e, f) = map(int, input().split())
A = sorted(list(set(filter(lambda x: 100 * x <= f and x, [i * a + j * b for (i, j) in product(range(31), range(16))]))))
B = [min(x * e, f - 100 * x) for x in A]
C = []
for i in range(len(A)):
	m = 0
	for k in range(29):
		if k * d <= B[i]:
			m = max(m, k * d + (B[i] - k * d) // c * c)
	C.append(m)
Table = [100 * a, 0]
for (x, y) in zip(A, C):
	if y / (100 * x + y) > Table[1] / Table[0]:
		Table = [100 * x + y, y]
print(Table[0], Table[1])


(a, b, c, d, e, f) = map(int, input().split())
(ans, ma) = ([0] * 2, 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 ma <= 100 * s / (w + s):
				ans = [w, s]
				ma = 100 * s / (w + s)
print(ans[0] + ans[1], ans[1])


(A, B, C, D, E, F) = map(int, input().split())
density = -1
ans = (0, 0)
for a in range(31):
	for b in range(31):
		for c in range(101):
			for d in range(101):
				water = 100 * a * A + 100 * b * B
				suger = c * C + d * D
				if water + suger > F or water == 0:
					break
				if water / 100 * E >= suger:
					tmp = 100 * suger / (water + suger)
					if tmp > density:
						density = tmp
						ans = (water + suger, suger)
print(*ans)


(a, b, c, d, e, f) = map(int, input().split())
l_water = set()
for i in range(f // (a * 100) + 1):
	for j in range(f // (b * 100) + 1):
		tmp = i * a * 100 + j * b * 100
		if 0 < tmp <= f:
			l_water.add(tmp)
l_sugar = set()
max_s = max(l_water) // 100 * e
for i in range(max_s // c + 1):
	for j in range(max_s // d + 1):
		tmp = i * c + j * d
		if 0 <= tmp <= max_s:
			l_sugar.add(tmp)
ans = [0, a * 100, 0]
for i in l_water:
	for j in l_sugar:
		if j <= i // 100 * e and i + j <= f:
			tmp = j / (i + j)
			if tmp > ans[0]:
				ans = [tmp, i + j, j]
print(*ans[1:])


(A, B, C, D, E, F) = map(int, input().split())
ws = set()
for i in range(F + 1):
	if 100 * A * i > F:
		break
	for j in range(F + 1):
		if 100 * A * i + 100 * B * j > F:
			break
		ws.add(100 * A * i + 100 * B * j)
ws.remove(0)
ss = set()
for i in range(F + 1):
	if C * i > F:
		break
	for j in range(F + 1):
		if C * i + D * j > F:
			break
		ss.add(C * i + D * j)
opt_w = 1
opt_s = -1
for w in ws:
	for s in ss:
		if w + s > F:
			continue
		if s * 100 > w * E:
			continue
		if opt_s * (w + s) < s * (opt_w + opt_s):
			(opt_w, opt_s) = (w, s)
print(opt_w + opt_s, opt_s)


(a, b, c, d, e, f) = list(map(int, input().split()))
maxdense = 0
ans = [0, 0]
for i in range(31):
	for j in range(31):
		for k in range(101):
			for l in range(101):
				water = 100 * a * i + 100 * b * j
				sugar = c * k + d * l
				if water == 0:
					break
				if water + sugar > f:
					break
				elif water / 100 * e >= sugar:
					dense = 100 * sugar / (water + sugar)
					if dense >= maxdense:
						maxdense = dense
						ans[0] = water + sugar
						ans[1] = sugar
print(*ans)


(a, b, c, d, e, f) = map(int, input().split())
F = f // 100
E = e / (e + 100)
ans = [100 * a, 0]
W = {i + j for i in range(0, F + 1, a) for j in range(0, F + 1, b)}
W = sorted(W)[1:]
for k in W:
	w = 100 * k
	for i in range(0, f + 1, c):
		for j in range(0, f + 1, d):
			s = i + j
			n = s / (w + s)
			if w + s > f or n > E:
				break
			if ans[1] / ans[0] < n:
				ans = [w + s, s]
print(ans[0], ans[1])


(A, B, C, D, E, F) = map(int, input().split())
from itertools import product
w = []
for (i, j) in product(range(F // (100 * A) + 1), range(F // (100 * B) + 1)):
	if 0 < 100 * A * i + 100 * B * j <= F:
		w.append(100 * A * i + 100 * B * j)
s = []
for (i, j) in product(range(E * F // (100 * C) + 1), range(E * F // (100 * C) + 1)):
	if C * i + D * j <= E * (F // 100):
		s.append(C * i + D * j)
w.sort()
s.sort()
ans = []
for a in w:
	for b in s:
		if a // 100 * E >= b and a + b <= F:
			ans.append([a + b, b])
		else:
			break
ans.sort(key=lambda x: x[1] / (x[0] + x[1]), reverse=True)
print(ans[0][0], ans[0][1])


(A, B, C, D, E, F) = map(int, input().split())
mizu = [0] * 31
mizu[0] = 1
satou = [0] * 1501
satou[0] = 1
noudo = 0
for i in range(31):
	if i >= A:
		mizu[i] += mizu[i - A]
	if i >= B:
		mizu[i] += mizu[i - B]
for i in range(1501):
	if i >= C:
		satou[i] += satou[i - C]
	if i >= D:
		satou[i] += satou[i - D]
for i in range(31):
	for j in range(1501):
		if mizu[i] > 0 and satou[j] > 0 and (i + j > 0):
			if j <= E * i and 100 * i + j <= F and (100 * j / (i + j) >= noudo):
				noudo = 100 * j / (i + j)
				ans = [100 * i + j, j]
print(*ans)


(a, b, c, d, e, f) = map(int, input().split())
a = 100 * a
b = 100 * b
dp1 = [0] * (f + 1)
dp2 = [0] * (f + 1)
for i in range(f + 1):
	if i % a == 0:
		if i + a <= f:
			dp1[i + a] = 1
for i in range(f + 1):
	if i == 0 or dp1[i] == 1:
		if i + b <= f:
			dp1[i + b] = 1
for i in range(f + 1):
	if i % c == 0:
		if i + c <= f:
			dp2[i + c] = 1
for i in range(f + 1):
	if i == 0 or dp2[i] == 1:
		if i + d <= f:
			dp2[i + d] = 1
ans = [-1, -1, -1]
for i in range(f + 1):
	if dp1[i] == 1:
		x = min(f - i, i // 100 * e)
		k = -1
		for j in range(x, -1, -1):
			if dp2[j] == 1 or j == 0:
				k = j
				if ans[0] < 100 * k / (i + k):
					ans = [100 * k / (i + k), i + k, k]
				break
print(str(ans[1]) + ' ' + str(ans[2]))


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


(a, b, c, d, e, f) = map(int, input().split())
a *= 100
b *= 100
den = -1
sugar = 0
water = 0
for i in range(0, f + 1, a):
	for j in range(0, f - i + 1, b):
		for k in range(0, f - i - j + 1, c):
			for l in range(0, f - i - j - k + 1, d):
				w = i + j
				s = k + l
				if w == 0:
					break
				if s / w > e / 100:
					continue
				x = s / (w + s)
				if x > den:
					den = x
					water = w
					sugar = s
		else:
			continue
		break
print(sugar + water, sugar)