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())
noudo_max = (100*E)/(100+E)


res = [-float('inf')]*3

i,j = 0,0
while 100*A*i<=F:
    j = 0
    while 100*A*i+100*B*j<=F:
        water = 100*A*i + 100*B*j
        sugar_max = F - water
        
        p = 0
        while C*p<=sugar_max:
            q = 0
            while C*p+D*q<=sugar_max:
                sugar = C*p+D*q
                if water+sugar!=0:
                    noudo = (100*sugar)/(water+sugar)
                    if noudo<=noudo_max and res[0]<noudo:
                        res = noudo,water,sugar
                q += 1
            p += 1
        j += 1
    i += 1

print(res[1]+res[2],res[2])

Solution (Python):
l = list(map(int,input().split()))	
a = l[0]
b = l[1]
c = l[2]
d = l[3]
e = l[4]
f = l[5]
ass=0
ans = [100*a,0]
for i in range((f//(100*b))+1):
    for j in range((f-100*b*i)//(100*a)+1):
        hj = f-100*b*i-100*a*j
        for k in range((hj//d+1)):
            if f-hj!=0:
                w = 100*k*d/(f-hj)
                if w <= e:
                    r = min((e*(f-hj)/100-d*k)//c,(hj-d*k)//c)
                    if ass <=(d*k+c*r)*100/(f-hj+d*k+c*r):
                        ans[0] = f-hj+d*k+c*r
                        ans[1] = d*k + c*r
                        ass = (d*k+c*r)*100/(f-hj+d*k+c*r)
print(str(int(ans[0]))+' '+str(int(ans[1])))

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
ans=-1
sugarwater=0
sugar=0
for i in range(101):
    for j in range(101):
        for k in range(101):
            for l in range(101):
                if (c*k+d*l) > e*(a*i+b*j):
                    break
                if (100 * a * i + 100 * b * j == 0 or 100 * a * i + 100 * b * j + c * k + d * l > f):
                    break
                if ans < 100*(c*k+d*l)/(100 * a * i + 100 * b * j + c*k + d*l):
                    ans=100*(c*k+d*l)/(100 * a * i + 100 * b * j + c*k + d*l)
                    sugarwater = 100 * a * i + 100 * b * j + c*k + d*l
                    sugar = c*k+d*l
print("{} {}".format(sugarwater,sugar))

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
ans=-1
sugarwater=0
sugar=0
for i in range(101):
    for j in range(101):
        for k in range(101):
            for l in range(101):
                if (c*k+d*l) > e*(a*i+b*j):
                    break
                if (100 * a * i + 100 * b * j == 0 or 100 * a * i + 100 * b * j + c * k + d * l > f):
                    break
                if ans < 100*(c*k+d*l)/(100 * a * i + 100 * b * j + c*k + d*l):
                    ans=100*(c*k+d*l)/(100 * a * i + 100 * b * j + c*k + d*l)
                    sugarwater = 100 * a * i + 100 * b * j + c*k + d*l
                    sugar = c*k+d*l
print("{} {}".format(sugarwater,sugar))

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

ab_list = set()

for i in range(0,f//100+1,a):
    for j in range(0, f//100-i+1, b):
        ab_list.add(100*(i+j))

ab_max = max(ab_list)

sug_max = int(ab_max*(e/100))

cd_list = set()

for i in range(0,sug_max+1, c):
    for j in range(0, sug_max-i+1, d):
        cd_list.add(i+j)

water = list(ab_list)
water.sort()

sugar = list(cd_list)
sugar.sort()

max_noudo = -1
ans = [0,-1]
for w in water:
    for s in sugar:
        if w==0 and s==0:
            continue
        if 100*s <= e*w and w+s <= f:
            noudo = s/(w+s)
            if noudo > max_noudo:
                max_noudo = noudo
                ans = [w+s, s]
                
print(*ans)

Solution (Python):
import itertools
a,b,c,d,e,f = [int(_) for _ in input().split()]

water = []
i = 0
while True:
    j = 0
    if i * 100 * a + j * 100 * b > f:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * 100 * a + j * 100 * b > f:
            break
        water.append(i * 100 * a + j * 100 * b)
        j += 1
    i += 1
set_water = sorted(set(water))

sugar = []
i = 0
while True:
    j = 0
    if i * c + j * d > f * e // 100:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * c + j * d > f * e // 100:
            break
        sugar.append(i * c + j * d)
        j += 1
    i += 1
set_sugar = sorted(set(sugar))

most_dense = 0
final_total = 0
final_sugar = 0
for i, j in itertools.product(range(0,len(set_water)), range(0, len(set_sugar))):
    density = set_sugar[j] / (set_water[i] + set_sugar[j])
    if density > most_dense and set_water[i] * e // 100 >= set_sugar[j] and set_water[i] + set_sugar[j] <= f:
        most_dense = density
        final_total = set_water[i]+set_sugar[j]
        final_sugar = set_sugar[j]

if final_total == 0:
    final_total = a * 100
print(final_total, final_sugar)

Solution (Python):


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

    ans_list = []

    for i in range(50):
        for j in range(50):
            for k in range(50):
                for l in range(50):
                    water = 100 * a * i + 100 * b * j
                    sugar = c * k + d * l
                    if water + sugar <= f and water > 0:
                        consentration = (100 * sugar) / (water + sugar)
                        if consentration <= (100 * e) / (100 + e):
                            ans_list.append([consentration, water, sugar])
    ans_list.sort(key=lambda x:x[0])
    print(ans_list[-1][1] + ans_list[-1][2], ans_list[-1][2])

if __name__ == '__main__':
    main()

Solution (Python):
a, b, c, d, e, f = map( int, input().split())
ans = 0
ansL = 0
ansM = 0
for i in range(30//a+1):
    for j in range((30-i)//b+1):
        L = a*i + b*j
        M = 0
        for k in range(f):
            if 100*L + k*c <= f and k*c <= L*e:
                m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d)
                M = max(M, m+k*c)
        if M+L != 0 and 100*L + M <= f and M <= L*e:
            if (M*100)/(M+L*100) > ans:
                ans = (M*100)/(M+L*100)
                ansL = L*100
                ansM = M
if ansL == 0:
    print('{} {}'.format(a*100,0))
else:
    print('{} {}'.format(ansL+ansM,ansM))

Solution (Python):
A,B,C,D,E,F = map(int, input().split())
 
import functools
import sys
sys.setrecursionlimit(10**5)
 
@functools.lru_cache(maxsize=None)
def calc_strength(sugar, water):
    if water == 0: return -1
    return sugar * 100 / (sugar + water)
 
@functools.lru_cache(maxsize=None)
def f(strength, sugar, water):
    cand = [(strength, sugar + water, sugar)]
    for x in ((C, 0), (D, 0), (0, 100*A), (0, 100*B)):
        s, w = sugar + x[0], water + x[1]
        if s + w <= F and s * 100 <= w * E:
            cand.extend([f(calc_strength(s, w), s, w)])
    return max(cand)

e=f(-1, 0, 0)
print(*f(-1, 0, 0)[1:])

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
w = []
for i in range(f // 100 + 2):
    for j in range(f // 100 + 2):
          t = 100 * (a * i + b * j)
          if 0 < t <= f:
              w.append(t)
s = []
for i in range(f // c + 2):
    for j in range(f // d + 2):
          t = c * i + d * j
          if t <= f:
              s.append(t)

ans_ws = -1
ans_s = -1
buf = -1

sat = (e * 100) / (100 + e)
for water in w:
    for sugar in s:
          ttl = (water + sugar)
          if ttl > f:
              continue
          concentration = (sugar * 100) / ttl
          if concentration <= sat:
              if buf < concentration:
                  buf = concentration
                  ans_ws = ttl
                  ans_s = sugar
print(ans_ws, ans_s)

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

import functools
import sys
sys.setrecursionlimit(10**5)

@functools.lru_cache(maxsize=None)
def calc_strength(sugar, water):
    if water == 0: return -1
    return sugar * 100 / (sugar + water)

@functools.lru_cache(maxsize=None)
def f(strength, sugar, water):
    cand = [(strength, sugar + water, sugar)]
    for x in ((C, 0), (D, 0), (0, 100*A), (0, 100*B)):
        s, w = sugar + x[0], water + x[1]
        if s + w <= F and s * 100 <= w * E:
            cand.append(f(calc_strength(s, w), s, w))
    return max(cand)
    
print(*f(-1, 0, 0)[1:])

Solution (Python):
from operator import itemgetter

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


def f(x, y):
    max_i = F // x
    max_j = F // y
    arr = []
    for i in range(max_i + 1):
        for j in range(max_j + 1):
            a = x * i + y * j
            if a <= F:
                arr.append(a)
    return list(set(arr))


water = f(100 * A, 100 * B)
sugar = f(C, D)

ans = []
for w in water:
    if w == 0:
        continue
    for s in sugar:
        if w + s <= F and s / w <= E / 100:
            ans.append((w + s, s, s / (w + s)))
ans = sorted(ans, key=itemgetter(2), reverse=True)
print(ans[0][0], ans[0][1])

Solution (Python):
a,b,c,d,e,f = input().split()
A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
F = int(f)

dictmax = {} 
for i in range(31):
	for j in range(31):
		for p in range(101):
			for q in range(101):
				ans_list = []
				if((100*(A*j+B*i))==0):
					break
				elif((100*(A*j+B*i)+(C*q+D*p))>F):
					break

				else:
					if((C*q+D*p) <=E*(A*j+B*i)):
						nodo = (C*q+D*p)/(100*(A*j+B*i)+(C*q+D*p))
						max_ans = 100*(A*j+B*i)+(C*q+D*p)
						sugar = C*q+D*p
	
						dictmax[nodo] = (max_ans,sugar)

max_nodo = max(dictmax.keys())
souryou = dictmax[max_nodo][0]
satou = dictmax[max_nodo][1]
print(souryou,satou)

Solution (Python):
def solve():
    
    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 ==0:
                        break
                    if w+s > F:
                        break
                    else:
                        if w/100 * E >= s:
                            dist = 100*s/(w+s)
                            memo[a,b,c,d] = dist
    
    max_v = max(memo.values())
    
    for k, v in memo.items():
        if v == max_v:
            print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
            break
 
if __name__ == '__main__':
	solve()

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

maximum = 0
max_water = 0
max_sugar = 0

queue = [[a, 0], [b, 0]]

visited = set()

while queue:
    now = queue.pop(0)
    now = tuple(now)

    if now in visited:
        continue

    visited.add(now)

    water, sugar = now

    if water * 100 + sugar > f:
        continue

    if (sugar / water) <= e:
        if maximum < sugar / (water*100):
            maximum = sugar / (water * 100)
            max_water = water
            max_sugar = sugar
    queue.append([water+a, sugar])
    queue.append([water+b, sugar])
    queue.append([water, sugar+c])
    queue.append([water, sugar+d])

if max_water == 0:
    print(min(a, b)*100, 0)
else:
    print(max_water*100 + max_sugar, max_sugar)

Solution (Python):


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

water = []
for i in range(0, F+1, A*100):
    for j in range(0, F+1, B*100):
        if i + j <= F:
            water.append(i + j)
water = sorted(list(set(water)), reverse=True)

water.pop(len(water)-1)

suger = []
for i in range(0, F+1, C):
    for j in range(0, F+1, D):
        if i + j <= F:
            suger.append(i + j)
suger = sorted(list(set(suger)))


ans_ws = water[0]
ans_s = 0
node = 0

for i in range(len(water)):
    for j in range(len(suger)):
        
        if water[i] + suger[j] > F:
            break
        
        if suger[j] / (water[i] + suger[j]) <= E / (E + 100):
            
            if suger[j] / (water[i] + suger[j]) > node:
                node = suger[j] / (water[i] + suger[j])
                ans_ws = water[i] + suger[j]
                ans_s = suger[j]
print(str(ans_ws) + " " + str(ans_s))

Solution (Python):
import bisect

def line_input(f, type):
    return f(map(type, input().split(" ")))

a,b,c,d,e,f = line_input(tuple, int)

max_dens = 0
ans_w = 0
ans_s = 0

wl = set()
for adx in range(0, f // (a*100) + 1):
    for bdx in range(0, f // (b*100) + 1):
        if adx == 0 & bdx == 0:
            continue

        wl.add(a * adx + b * bdx)

sl = set()
for cdx in range(0, f // c + 1):
    for ddx in range(0, f // d + 1):
        sl.add(c * cdx + d * ddx)

for w in wl:
    if w > f:
        continue

    for s in sl:
        cap = f - w * 100
        C = w * 100 + s

        dens = s / C
        if (C <= f) & (s <= e * w) & (max_dens <= dens):
            max_dens = dens
            ans_w = C
            ans_s = s

print(ans_w, ans_s)

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

A = []
i = 0
while(100*a*i < f):
    A.append(100*a*i)
    i += 1

B = []
i = 0
while(100*b*i < f):
    B.append(100*b*i)
    i += 1

AB = set()
for aa in A:
    for bb in B:
        if aa+bb < f:
            AB.add(aa+bb)
AB.remove(0)

max_sugar = e * f / (100.0 + e)

C = []
i = 0
while(c*i <= max_sugar):
    C.append(c*i)
    i += 1

D = []
i = 0
while(d*i <= max_sugar):
    D.append(d*i)
    i += 1

CD = set()
for cc in C:
    for dd in D:
        if cc+dd <= max_sugar:
            CD.add(cc+dd)





MAX_DENS = e/(e+100.0)

max_dens = -1
max_ws = ()
for water in AB:
    for sugar in CD:
        weight = water + sugar
        dens = sugar / weight
        if weight > f or dens > MAX_DENS:
            continue
        if max_dens < dens:
            
            max_dens = dens
            max_ws = (weight, sugar)

print('%d %d' % max_ws)

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

upper_concentration = E / (100 + E)

def concentration(sugar, water):
    if sugar == 0 and water == 0:
        return False
    c = sugar / (sugar + water)
    if c > upper_concentration:
        return False
    else:
        return c

AB = []
for ia in range(0, int(F / 100 / A) + 1):
    ib = 0
    if ia == 0 and ib == 0:
        continue
    while 100 * (A * ia + B * ib) <= F:
        AB.append([ia, ib])
        ib += 1

c_max = 0
sugar_max = 0
sugar_water_max = 0
water_max = 0

for ia, ib in AB:
    water = 100 * (A * ia + B * ib)
    water_max = max(water_max, water)
    res_water = F - water
    for ic in range(0, int(res_water / C) + 1):
        for id in range(0, int(res_water / D) + 1):
            sugar = C * ic + D * id
            if sugar > res_water:
                break
            c = concentration(sugar, water)
            if not c:
                continue
            if c_max <= c:
                c_max = c
                sugar_max = sugar
                sugar_water_max = sugar + water
if sugar_max == 0:
    print(water_max, 0)
else:
    print(sugar_water_max, sugar_max)

Solution (Python):

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

    
    
    


    mizu=[]
    sato=[]


    x = int(f/100/a) +1
    y = int(f/100/b) +1

    for i in range(x):
        for j in range(y):
            mizu.append(i*100*a + j*100*b)

    mizu = [i for i in mizu if i <= f]
    mizu = list(set(mizu))
    mizu.sort()

    tokeru = int(f/100) * e
    x = int(tokeru / c) +1
    y = int(tokeru / d) +1

    for i in range(x):
        for j in range(y):
            sato.append(i*c + j*d)

    sato = [i for i in sato if i < tokeru]
    sato = list(set(sato))
    sato.sort()



    tmp =0

    for i in mizu:
        for j in sato:
            if i + j <= f and i + j !=0:
                if int(i/100)*e >=j:
                    if tmp <= (100*j) / (i + j):
                        tmp = (100*j) / (i + j)
                        ans = str(i+j) + " " + str(j)

    print(ans)


if __name__ == "__main__":
        main()

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
W = []
for i in range(F // (A * 100) + 1):
  for j in range(F // (B * 100) + 1):
    if (A * i + B * j) and (A * i + B * j) * 100 <= F:
      W.append(A * i + B * j)
c = [0 for w in W]
for k, w in enumerate(W):
  s_upper = min(w * E, F - w * 100)
  s_max = 0
  for i in range(s_upper // C + 1):
    for j in range(s_upper // D + 1):
      if C * i + D * j <= s_upper:
        s_max = max(C * i + D * j, s_max)
  c[k] = [s_max / (s_max + w * 100), s_max, w]
ans = sorted(c, key=lambda x: x[0], reverse=True)[0]
print(ans[1] + ans[2] * 100, ans[1])

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

waters = set()
for w1 in range(0,F+1,B):
    if w1*100 > F: break
    for w2 in range(0,F+1,A):
        w = (w1+w2)*100
        if w > F: break
        if w==0: continue
        waters.add(w)

sugars = set()
for s1 in range(0,F+1,D):
    if s1 > F: break
    for s2 in range(0,F+1,C):
        s = s1+s2
        if s > F: break
        sugars.add(s)

ans_r = -1
ans_s = ans_w = None
for w in sorted(waters):
    if w > F: break
    for s in sorted(sugars):
        if w+s > F: break
        if s*100 > w*E: break
        r = 100*s/(s+w)
        if r > ans_r:
            ans_r = r
            ans_w = w
            ans_s = s
print(ans_s+ans_w, ans_s)

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


xs = []
ys = []
def dens(x,y):
    if x+y==0:
        return(-1)
    else:
        return(y/(x+y))
for i in range(31):
    for j in range(16):
        if 100*A*i + 200*B*j <= F:
            xs.append(100*A*i + 200*B*j)
for i in range(3001):
    for j in range(1501):
        if C*i + D*j <= F:
            ys.append(C*i + D*j)
density = 0
water = 100*A
sugar = 0
for x in xs:
    for y in ys:
        if x+y > F or 100*y > E*x:
            continue
        nd = dens(x,y)
        if nd > density:
            density = nd
            sugar = y
            water = x
print(str(water+sugar) + " " + str(sugar))

Solution (Python):
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)

Solution (Python):

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

temp = 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):
                w = 100 * A * i + 100 * B * j
                s = C * k + D * l
                if w == 0:
                    break
                if s > E * (A * i + B * j):
                    break
                if w + s > F:
                    break
                if s / (w + s) > temp:
                    temp = s / (w + s)
                    ans1 = w + s
                    ans2 = s

print(ans1, ans2)

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

maxr = 0
result = 0, 0

for a in range(31):
    for b in range(31):
        l = 100 * a * A + 100 * b * B
        if l <= F:
            maxs100 = E * l
            d = 0
            while d * D * 100 <= maxs100:
                c1 = (maxs100 - d * D * 100) // (C * 100)
                c2 = (F - l - d * D) // C
                c = min(c1, max(0, c2)) 
                s = c * C + d * D
                w = l + s
                if 0 < w <= F:
                    r = 100 * s / w
                    if r >= maxr:
                        maxr = r
                        result = w, s
                d += 1

print(*result)

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

w = []
i = -1
while True:
    i += 1
    if a*i > f:
        break
    j = -1
    while True:
        j += 1
        if a*i+b*j > f:
            break
        w.append(a*i+b*j)
w = list(set(w))

s = []
i = -1
while True:
    i += 1
    if c*i > f:
        break
    j = -1
    while True:
        j += 1
        if c*i+d*j > f:
            break
        s.append(c*i+d*j)
s = list(set(s))

ans = [0, 0, 0]
for y in w:
    if y == 0:
        continue
    for x in s:
        if x+y <= f and e*y//100 >= x:
            ans = max(ans, [x/y, x+y, x])

txt = str(ans[1]) + " " + str(ans[2])
print(txt)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
max_con = (100*E)/(100+E)
W,S = [],[]
for i in range(0,F+1,100*A):
    j = 0
    while i+100*B*j<=F:
        W.append(i+100*B*j)
        j += 1
setW = set(W)
for i in range(0,F+1,C):
    j = 0
    while i+D*j<=F:
        S.append(i+D*j)
        j += 1
setS = set(S)
con = -1
total, ans_s = 0,0
for w in setW:
    for s in setS:
        if w==s==0:
            continue
        if (100*s)/(w+s)<=max_con and s+w<=F and con<(100*s)/(w+s):
            con = (100*s)/(w+s)
            total = w+s
            ans_s = s
print(total, ans_s)

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


def create_candidates(w_x, w_y, F):
    """
    >>> create_candidates(2,11,15)
    {0, 2, 4, 6, 8, 10, 11, 12, 13, 14, 15}
    """
    candidates = set()
    for x in range(F):
        if w_x * x > F:
            break
        for y in range(F):
            a = w_x * x + w_y * y
            if a <= F:
                candidates.add(a)
            else:
                break
    return candidates


candidates_a = create_candidates(100 * A, 100 * B, F)
candidates_b = create_candidates(C, D, F)
candidates_a.remove(0)

max_dense = -float("inf")
max_a = -1
max_b = -1
for a in candidates_a:
    for b in candidates_b:
        if a + b <= F and b <= a * E / 100 and 100 * b / (a + b) > max_dense:
            max_dense = 100 * b / (a + b)
            max_a = a
            max_b = b

print(max_a + max_b, max_b)

Solution (Python):
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 / water < new_s / new_w:
                    water = new_w
                    sugar = new_s
print(water + sugar, sugar)

Solution (Python):
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)

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


noudo=0

satomizu=0
sato=0
Flug=False

NA1=F/(A*100)
NA=int(NA1)
NB1=F/(B*100)
NB=int(NB1)
NC1=F/C
NC=int(NC1)
ND1=F/D
ND=int(ND1)
if B%A ==0:
    NB=1
if D%C ==0:
    ND=1

jyogen=E/(100+E)
for a in range(1,NA+2):
    for b in range(NB+1):
        for c in range(NC+1):
            for d in range(ND+1):
                if  noudo<=(c*C+d*D)/(100*a*A +100*b*B+c*C+d*D) and (c*C+d*D)/(100*a*A +100*b*B+c*C+d*D)<=jyogen and (100*a*A +100*b*B+c*C+d*D)<=F:
                    noudo=(c*C+d*D)/(100*a*A +100*b*B+c*C+d*D)
                    satomizu=100*a*A +100*b*B+c*C+d*D
                    sato=c*C+d*D
                    if sato/satomizu == jyogen:
                        Flug=True
                        break
    if Flug==True:
            break
print(str(satomizu)+" "+str(sato))

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
water=[]
suguar=[]
for i in range((f+1)//100):
    for j in range((f+1)//100):
        x=100*i*a+100*j*b
        if 1<=x<=f:
            water.append(x)
for i in range(f+1):
    for j in range(f+1):
        y=c*i+d*j
        if y<=f:
            suguar.append(y)
ans=0
for i in water:
    for j in suguar:
        total=i+j
        if total<=f:
            if j<=i//100*e:
                con=100*j/(i+j)
                if ans<=con:
                    ans=con
                    ans_2=total
                    ans_3=j
print(ans_2,ans_3)

Solution (Python):
A, B, C, D, E, F = list(map(int, input().split()))
 
water = [1]
for i in range(30):
	water.append(0)
 
for i in range(31):
	if water[i] == 1:
		if (i + A) * 100 <= F:
			water[i + A] = 1
 
		if (i + B) * 100 <= F:
			water[i + B] = 1
 
K = []
 
for i in range(1, 31):
	if water[i] == 1:
		sugar = [1]
		X = min(i * E, F - 100 * i)
		for j in range(X):
			sugar.append(0)
 
		for j in range(X + 1):
			if sugar[j] == 1:
				if j + C <= X:
					sugar[j + C] = 1
 
				if j + D <= X:
					sugar[j + D] = 1
		sugar.reverse()
		s = sugar.index(1)
		WS = ((100 * (X - s) / (100 * i + X - s)), 100 * i + X - s, X - s)
		K.append(WS)
 
K = sorted(K)
print(K[-1][1], K[-1][2])

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
water=[]
sugar=[]
ans,ans_2,con=0,0,0
for i in range(f//100+1):
    for j in range(f//100+1):
        x=100*a*i+100*j*b
        if 0<x<=f:
            water.append(x)
for i in range(f):
    for j in range(f):
        y=c*i+d*j
        if y<=f:
            sugar.append(y)
sugar=list(set(sugar))
for i in water:
    for j in sugar:
        if i+j<=f:
            if j<=i//100*e:
                now=(100*j)/(i+j)
                if con<=now:
                    ans=i+j
                    ans_2=j
                    con=now
print(ans,ans_2)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
water=[]
sugar=[]
ans,ans_2,con=0,0,0
for i in range(f//100+1):
    for j in range(f//100+1):
        x=100*a*i+100*j*b
        if x<=f:
            water.append(x)
for i in range(f):
    for j in range(f):
        y=c*i+d*j
        if y<=f:
            sugar.append(y)
sugar=list(set(sugar))
for i in water:
    for j in sugar:
        if i+j<=f:
            if i!=0 or j!=0:
                if j<=(i//100)*e:
                    now=(100*j)/(i+j)
                    if con<=now:
                        ans=i+j
                        ans_2=j
                        con=now
print(ans,ans_2)

Solution (Python):
A,B,C,D,E,F=map(int, raw_input().split())
max_sugar=int(float(E)/(100+E)*F)

a=set()
for i in range(max_sugar+1):
	for j in range(max_sugar):
		
		if i*C+D*j<= max_sugar:
			a.add(i*C+D*j)

b=set()
cnt=F/100
for i in range(cnt+1):
	for j in range(cnt+1):
		if A*i*100+B*j*100<=F and A*i*100+B*j*100!=0:
			b.add(A*i*100+B*j*100)




noudo=float(E)/(100+E)*100
max_noudo=0
ans=A*100,0

for i in a:
	for j in b:
		t_noudo=float(i)/(i+j)*100
		
		if t_noudo <= noudo and t_noudo > max_noudo and i+j<=F:
			
			max_noudo=t_noudo
			ans=i+j,i

print ans[0],ans[1]

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

waters = set()
for wb in range(0,F+1,100*B):
    wa = 0
    while wa + wb <= F:
        waters.add(wa + wb)
        wa += 100*A
waters.remove(0)

sugars = set()
for sd in range(0,F+1,D):
    sc = 0
    while sc + sd <= F:
        sugars.add(sc + sd)
        sc += C

best = -1
best_w = best_s = 0
for w in sorted(waters):
    for s in sorted(sugars):
        if 100*s > w*E: continue
        if w+s > F: continue
        if best < 100*s / (w+s):
            best = 100*s / (w+s)
            best_w = w
            best_s = s

print(best_w+best_s, best_s)

Solution (Python):
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)

Solution (Python):
from math import ceil, floor


def exist(A, B, x):
    """
    check if i and j exist such that Ai + Bj = x
    """
    max_i = x // A
    for i in range(max_i + 1):
        if (x - A * i) % B == 0:
            return True
    else:
        return False


A, B, C, D, E, F = [int(elem) for elem in input().split(' ')]

max_density = 0.
status_when_max_dens = {'water': 0, 'sugar': 0}
for x in range(1, F + 1):
    if exist(100 * A, 100 * B, x):
        for y in range(F - x + 1):
            if exist(C, D, y):
                density = y / (x + y)
                if (density >= max_density)\
                and (y <= x / 100 * E)\
                and (x + y <= F):
                    max_density = density
                    status_when_max_dens['water'] = x
                    status_when_max_dens['sugar'] = y


water = status_when_max_dens['water']
sugar = status_when_max_dens['sugar']
print(water + sugar, sugar)