Problem:
 Score : 300 points    Problem Statement Snuke is making sugar water in a beaker.
Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.   Operation 1: Pour 100A grams of water into the beaker.  Operation 2: Pour 100B grams of water into the beaker.  Operation 3: Put C grams of sugar into the beaker.  Operation 4: Put D grams of sugar into the beaker.   In our experimental environment, E grams of sugar can dissolve into 100 grams of water.  Snuke will make sugar water with the highest possible density.  The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.
Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.
If there is more than one candidate, any of them will be accepted.  We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent.
Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.      Constraints  1 \leq A < B \leq 30  1 \leq C < D \leq 30  1 \leq E \leq 100  100A \leq F \leq 3  000  A , B , C , D , E and F are all integers.         Inputs Input is given from Standard Input in the following format:  A  B  C  D  E  F       Outputs Print two integers separated by a space.
The first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.        Sample Input 1 1 2 10 20 15 200      Sample Output 1 110 10  In this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.  We can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.
It is not possible to make sugar water with higher density.
For example, the following sequences of operations are infeasible:   If we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.  If we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.        Sample Input 2 1 2 1 2 100 1000      Sample Output 2 200 100  There are other acceptable outputs, such as:  400 200  However, the output below is not acceptable:  300 150  This is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.       Sample Input 3 17 19 22 26 55 2802      Sample Output 3 2634 934

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math






def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    A,B,C,D,E,F = inputMap()
    A = A*100
    B = B*100
    
    ans_muzu = 0
    ans_satou = 0
    ans = -1
    
    for i in range(0, F, A):
        for j in range(0, F, B):
            for ii in range(0, F, C):
                for jj in range(0, F, D):
                    
                    if F < i + j + ii + jj:
                        continue
                        
                    mizu = i+j
                    satou = ii+jj
                    
                    if mizu == 0:
                        continue
                    
                    if satou / mizu > E / 100:
                        continue
                    
                    tmp = (satou / (satou+mizu)) * 100
                    if ans < tmp:
                        ans = tmp
                        ans_muzu = mizu
                        ans_satou = satou
                        
    print("{} {}".format(ans_muzu+ans_satou, ans_satou))
    
    
    
            	
if __name__ == "__main__":
	main()

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

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

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
conc = 0
total = 0
sugar = 0
for i in range((f-100*a)//d + 1):
    for j in range((f-100*a-d*i)//c + 1):
        sugar_total = d*i + c*j
        conc_prep = sugar_total/(sugar_total+100*a)
        if sugar_total <= e*a and conc <= conc_prep:
            conc = conc_prep
            total = sugar_total + 100*a
            sugar = sugar_total

for i in range(1, f//(100*b)+1):
    diff = f - 100*b*i
    for j in range(diff//(100*a)+1):
        sugar_max = diff - 100*a*j
        for k in range(sugar_max//d + 1):
            for l in range((sugar_max - k*d)//c + 1):
                sugar_total = k*d + l*c
                total_prep = sugar_total + 100*(b*i + a*j)
                conc_prep = sugar_total/total_prep
                if sugar_total <= e*(b*i+a*j) and conc <= conc_prep:
                        conc = conc_prep
                        total = total_prep
                        sugar = sugar_total
print(total, sugar)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
wans,sans,Cans=100*a,0,0
for p in range(1+(f//100*a)):
    for q in range(1+(f//100*b)):
        water=100*(a*p+b*q)
        if water>f or water==0:
            pass
        else:
            limit=(a*p+b*q)*e
            for r in range(1+(limit//c)):
                for s in range(1+(limit//d)):
                    suger=r*c+s*d
                    if water+suger>f or c*r+d*s>limit:
                        pass
                    else:
                        C=suger/(water+suger)
                        if C>=Cans:
                            wans,sans,Cans=water,suger,C
print(wans+sans,sans)

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

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

water = []
for i in range(A+1):
    for j in range(B+1):
        if (100*A*i + 100*B*j )< F and (A*i + B*j) > 0:
            water.append(100*A*i+100*B*j)

sugar = []
for i in range(C+1):
    for j in range(D+1):
        if C*i + D*j < F:
            sugar.append(C*i+D*j)
            
water.sort()
sugar.sort()
    
MAX = 0
MAXSUGAR = 0
MAXWEIGHT = 0
tmpsugar = 0
for i in range(len(water)):
    for j in range(len(sugar)):
        tmpsugar = sugar[j]
        while (water[i]+tmpsugar)<=F and tmpsugar <= water[i]*E//100:
            if MAX  <= 100*tmpsugar/(water[i]+tmpsugar):
                MAX  = 100*tmpsugar/(water[i]+tmpsugar)
                MAXSUGAR = tmpsugar
                MAXWEIGHT = water[i]+tmpsugar
            if tmpsugar == 0:
                break
            tmpsugar += sugar[j]

print(str(MAXWEIGHT)+" "+str(MAXSUGAR))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n, a = II(), II()
    print(n * n - a)
    return


def B():
    _ = II()
    k = II()
    x = LI()
    ans = 0
    for xi in x:
        ans += min(xi, k - xi)
    print(ans * 2)
    return


def C():
    a, b, c, d, e, F = LI()
    ans = [min(a,b)*100, 0]
    for ai in range(F // (100 * a) + 1):
        for bi in range((F - 100 * ai * a) // (100 * b) + 1):
            if ai == bi == 0:
                continue
            ab = ai * 100 * a + bi * 100 * b
            for ci in range((F - ab) // c + 1):
                for di in range((F - ab - ci * c) // d + 1):
                    if (ai * a + bi * b) * e < ci * c + di * d:
                        continue
                    if ans[1] / ans[0] < (ci * c + di * d) / (ab + ci * c + di * d):
                        ans = [ab + ci * c + di * d, ci * c + di * d]
    print(*ans)
    return


def D():
    return


if __name__ == '__main__':
    C()

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

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
ans = 0
W = set()
S = set()

for i in range(F):
  x1 = 100 * A * i
  if x1 > F:
    break
  for j in range(F):
    x2 = x1 + 100 * B * j
    if x2 > F or x2 == 0:
      break
    W.add(x2)
for i in range(F):
  y1 = C * i
  if y1 > F:
    break
  for j in range(F):
    y2 = y1 + D * j
    if y2 > F:
      break
    S.add(y2)

W = list(set(W))
S = list(set(S))

for i in range(len(W)):
  for j in range(len(S)):
    tmp = S[j]/W[i]
    tmp1 = S[j] + W[i]
    if tmp1 <= F and ans <= tmp <= E/100:
      ans = tmp
      ans1 = tmp1
      ans2 = S[j]
print(ans1, ans2)

Solution (Python):
import itertools
import math

LIM = 50



def do():
    ans = 0
    A,B,C,D,E,F= list(map(int,input().split(" ")))
    waters = []
    for i in range(31):
        for j in range(31):
            water = A*i* 100+B*j* 100
            if water <= F and water != 0:
                waters.append(water)
    solts = []
    for i in range(3000):
        for j in range(3000):
            solt = C * i + D * j
            if solt > E * F /100:
                break
            solts.append(solt)

    max_nodo = -1
    ans_water = 0
    ans_solt = 0
    for solt in solts:
        for water in waters:
            if solt/(water/100) <= E:
                if (100 * solt)/(solt+water) >= max_nodo and water + solt <= F:
                    max_nodo =(100 * solt)/(solt+water)
                    ans_water = water + solt
                    ans_solt = solt

    print(ans_water,ans_solt)





if __name__ == "__main__":
    do()

Solution (Python):
import itertools
import math

LIM = 50



def do():
    ans = 0
    A,B,C,D,E,F= list(map(int,input().split(" ")))
    waters = []
    for i in range(31):
        for j in range(31):
            water = A*i* 100+B*j* 100
            if water <= F and water != 0:
                waters.append(water)
    solts = []
    for i in range(3000):
        for j in range(3000):
            solt = C * i + D * j
            if solt > E * F /100:
                break
            solts.append(solt)

    max_nodo = -1
    ans_water = 0
    ans_solt = 0
    for solt in solts:
        for water in waters:
            if solt/(water/100) <= E:
                if (100 * solt)/(solt+water) >= max_nodo and water + solt <= F:
                    max_nodo =(100 * solt)/(solt+water)
                    ans_water = water + solt
                    ans_solt = solt

    print(ans_water,ans_solt)





if __name__ == "__main__":
    do()

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
dpw=[False]*31
dps=[False]*1501
dpw[0]=True
dps[0]=True
for i in range(1,31):
    if i>=a:
        dpw[i]=dpw[i] or dpw[i-a]
    if i>=b:
        dpw[i]=dpw[i] or dpw[i-b]
for i in range(1,1501):
    if i>=c:
        dps[i]=dps[i] or dps[i-c]
    if i>=d:
        dps[i]=dps[i] or dps[i-d]
Va=100*a
Vs=0
for i in range(1,31):
    for j in range(1501):
        if dpw[i] and dps[j]:
            Sum=100*i+j
            if Sum<=f and j<=i*e:
                if j/Sum>Vs/Va:
                    Va=Sum
                    Vs=j
print(Va,Vs)

Solution (Python):



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

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
water = [100*a*A + 100*b*B for B in range(t+1) for A in range(s+1) if 100*a*A + 100*b*B != 0]
suger = [c*C + d*D for D in range(v+1) for C in range(u+1)]
ans1 = 0
ans2 = 0
water = list(set(water))
suger = list(set(suger))
for W in water:
    for S in suger:
        if W + S <= f:
            if W*e >= 100*S:
                if concentration < S/(W+S):
                    concentration = S/(W+S)
                    ans1 = W+S
                    ans2 = S
if ans1 == 0:
    ans1 = 100*a
print(ans1,ans2)

Solution (Python):



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

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
water = []
suger = []
for A in range(s+1):
    for B in range(t+1):
        if 100*a*A + 100*b*B != 0:
            water.append(100*a*A + 100*b*B)

for C in range(u+1):
    for D in range(v+1):
        suger.append(c*C + d*D)

ans1 = 0
ans2 = 0
for W in water:
    for S in suger:
        if W + S <= f:
            if W//100*e >= S:
                if concentration < S/(W+S):
                    concentration = S/(W+S)
                    ans1 = W+S
                    ans2 = S
if ans1 == 0:
    ans1 = 100*a
print(ans1,ans2)

Solution (Python):



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

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
solution = 0
suger = 0
for A in range(s+1)[::-1]:
    for B in range(t+1)[::-1]:
        for C in range(u+1)[::-1]:
            for D in range(v+1)[::-1]:
                if 100*a*A + 100*b*B + c*C + d*D <= f:
                    if (a*A+b*B)*e >= (c*C + d*D):
                        if 100*a*A + 100*b*B + c*C + d*D != 0:
                            if concentration < (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D):
                                concentration = (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D)
                                solution = 100*a*A + 100*b*B + c*C + d*D
                                suger = c*C + d*D
if solution == 0:
    solution = 100*a
print(solution,suger)

Solution (Python):



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

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
solution = 0
suger = 0
for A in range(s+1):
    for B in range(t+1):
        for C in range(u+1):
            for D in range(v+1):
                if 100*a*A + 100*b*B + c*C + d*D <= f:
                    if (a*A+b*B)*e >= (c*C + d*D):
                        if 100*a*A + 100*b*B + c*C + d*D != 0:
                            if concentration < (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D):
                                concentration = (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D)
                                solution = 100*a*A + 100*b*B + c*C + d*D
                                suger = c*C + d*D
if solution == 0:
    solution = 100*a
print(solution,suger)

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100
w = set()
for i in range(f):
    _w = i * a
    if f < _w: break
    for j in range(f):
        __w = _w + j * b
        if f < __w: break
        w.add(__w)
w.remove(0)
s = set()
for i in range(f):
    _s = i * c
    if f < _s: break
    for j in range(f):
        __s = _s + j * d
        if f < __s: break
        s.add(__s)
m = -1
ans = (0, 0)
for _w in w:
    for _s in s:
        if 100 * _s <= e * _w and _w + _s <= f:
            t = 100 * _s / (_s+_w)
            if m < t:
                ans = (_w+_s, _s)
                m = t
print(*ans)

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

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
wl = set()
for ia in range(F//A+1):
    for ib in range(F//B+1):
        ww = ia*A*100+ib*B*100
        if 0 < ww <= F:wl.add(ww)

ws = set()
for ic in range((F*E)//(100*C) + 1):
    for idd in range((F*E)//(100*D)+1):
        ss = ic*C + idd*D
        if ss <= (F*E)/100:ws.add(ss)

g = 0
sw = sg = 0
for www in sorted(wl):
    ms = (www * E) // 100
    for c in sorted(ws):
        if c > ms:break
        else:
            if (c/www) <= E and (www+c) <=F:
                if g < c/(c+www):
                    g = c/(c+www)
                    sw = www
                    sg = c
if g == 0:
    print(100*A,0)
else:
    print(sg+sw,sg)

Solution (Python):
a,b,c,d,e,f = map(int,input().split())
mizu = []
satou = []
tmp_ans = []
ans = -1
ans_i = 0
ans_j = 0
for i in range(31):
    for j in range(31):
        tmp = a * 100 * i + b * 100 * j
        if tmp <= f:
            mizu.append(tmp)
mizu = list(set(mizu))
for i in range(101):
    for j in range(101):
        tmp = c * i + d * j
        if tmp <= f:
            satou.append(tmp)
satou = list(set(satou))
for i in mizu:
    for j in satou:
        if i + j <= f:
            if i + j != 0 and i != 0 and i // 100 * e >= j:
                if ans < j /(i + j):
                    ans = j / (i + j)
                    ans_i = i
                    ans_j = j
print(ans_i + ans_j,ans_j)

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

water = []
for i in range(32):
    if 100 * A * i > F:
        continue
    for j in range(32):
        if 100 * A * i + 100 * B * j > F:
            continue
        if i == 0 and j == 0:
            continue
        water.append(100 * A * i + 100 * B * j)

sugar = [0] * (F * F)
for i in range(F):
    if i * C > F:
        continue
    for j in range(F):
        if i * C + j * D > F:
            continue
        sugar.append(C * i + D * j)
sugar = list(set(sugar))

water.sort()
sugar.sort()
ans = 0
wa = 0
su = 0
for i in water:
    for j in sugar:
        if i + j <= F:
            if ans <= (100 * j / (i + j)) and (i / 100 * E) >= j:
                ans = (100 * j / (i + j))
                wa = i
                su = j

print(wa + su, su)

Solution (Python):
a ,b ,c ,d ,e ,f = map(int,input().split())
water = set()
sugar = set()
cou = 0
co = 0

for i in range(f//b):
    cou = 0
    while 100 * b * i + 100 * a * cou <= f:
        water.add(100 * b * i + 100 * a * cou)
        cou += 1
water = sorted(water)


for i in range(f//d):
    cow = 0
    while d * i + c * cow <= f:
        sugar.add(d * i + c * cow)
        cow += 1
sugar = sorted(sugar)




ans = [0,0,0]

for wat in water:
    for sug in sugar:
        if wat or sug:
            if wat + sug <= f and e / (100 + e) >= sug/(wat+sug):
                if ans[0] <= sug/(wat+sug):
                    ans = [sug/(wat+sug), wat+sug, sug]
print(ans[1],ans[2])

Solution (Python):

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

amax = F // (100 * A)
bmax = F // (100 * B)
cmax = F // C
dmax = F // D

ans = 0
summ = 0
suge = 0


for a in range(amax+1):

    for b in range(bmax+1):

        for c in range(cmax+1):

            for d in range(dmax+1):


                if 100*A*a + 100*B*b + C*c + D*d <= F and (A*100*a+B*100*b)*E >= 100*(C*c+D*d):

                    if A*100*a+B*100*b+C*c+D*d !=0 and ans < 100*(C*c+D*d)/(A*100*a+B*100*b+C*c+D*d):

                        ans = 100*(C*c+D*d)/(A*100*a+B*100*b+C*c+D*d)
                        summ = A*100*a+B*100*b+C*c+D*d
                        suge = C*c+D*d

if summ == 0:
    summ = 100*A
print (summ,suge)

Solution (Python):
row = list(map(int, input().split()))
max_water= 0
max_sugar = 0
max_percent = 0

for w1 in range(int(row[5]/(row[0]*100))+1):
    for w2 in range(int((row[5]-w1*100*row[0])/(row[1]*100))+1):
        for s1 in range(int((row[5]-w1*100*row[0]-w2*row[1]*100)/row[2])+1):
            for s2 in range(int((row[5]-w1*100*row[0]-w2*row[1]*100-s1*row[2])/row[3])+1):
                water = w1*100*row[0]+w2*row[1]*100
                sugar = s1*row[2]+s2*row[3]
                if sugar + water != 0 and water != 0:
                    percent = 100*sugar/(water + sugar)
                    if max_percent < percent <= 100*row[4]/(100+row[4]):
                        max_water = water
                        max_sugar = sugar
                        max_percent = percent
if max_water == 0:
    if row[0]*100 <= row[5]:
        max_water = row[0]*100
    elif row[1]*100 <= row[5]:
        max_water = row[1]*100

print(max_water+max_sugar, max_sugar)

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

maxStrength = 0
ansMass = 0
ansSugar = 0
for i in range(0, F+1, 100*A):
        for j in range(0, F-i+1, 100*B):
                for k in range(0, F-i-j+1, C):
                        for l in range(0, F-i-j-k+1, D):
                                a = i + j
                                b = k + l
                                mass = a + b
                                if (a / 100)*E >= b and mass <= F and mass != 0:
                                        strength = (100*b) / mass
                                        if strength >= maxStrength:
                                                maxStrength = strength
                                                ansMass = mass
                                                ansSugar = b

print(ansMass, ansSugar)

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

i=0
mizu=[]
while a*i*100<=f:
    j=0
    while b*j*100<=f:
        if a*i+b*j!=0 and (not (a*i+b*j)*100 in mizu):
            mizu.append((a*i+b*j)*100)
        j+=1
    i+=1



i=0
sato=[]
while c*i<=f:
    j=0
    while d*j<=f:
        if not c*i+d*j in sato:
            sato.append(c*i+d*j)
        j+=1
    i+=1


ans=[sato[0],mizu[0]]
for i in range(len(mizu)):
    for j in range(len(sato)):
        if sato[j]+mizu[i]<=f and sato[j]*100<=e*mizu[i]:
            if ans[0]/(ans[0]+ans[1])<sato[j]/(mizu[i]+sato[j]):
                ans=[sato[j], mizu[i]]

print("{0} {1}".format(ans[0]+ans[1], ans[0]))

Solution (Python):
A,B,C,D,E,F=map(int, input().split())
cnt_A=0
cnt_B=0
cnt_C=0
cnt_D=0
max_noudo=0
water=A*100
sugar=0
while cnt_A*100*A <= F:
  cnt_B=0
  while cnt_B*100*B <= F-cnt_A*100*A:
    cnt_C=0
    while cnt_C*C <= F-cnt_A*100*A-cnt_B*100*B:
      cnt_D=0
      while cnt_D*D <= F-cnt_A*100*A-cnt_B*100*B-cnt_C*C:
        if (cnt_A*A+cnt_B*B)*E >= cnt_C*C+cnt_D*D >0:
          if max_noudo < 100*(cnt_C*C+cnt_D*D)/(cnt_A*A+cnt_B*B):
            max_noudo = 100*(cnt_C*C+cnt_D*D)/(cnt_A*A+cnt_B*B)
            water=cnt_A*A*100+cnt_B*B*100+cnt_C*C+cnt_D*D
            sugar=cnt_C*C+cnt_D*D
        cnt_D+=1
      cnt_C+=1
    cnt_B+=1
  cnt_A+=1

print(water,sugar)

Solution (Python):
A,B,C,D,E,F=map(int, input().split())
cnt_A=0
cnt_B=0
cnt_C=0
cnt_D=0
max_noudo=0
water=A*100
sugar=0
while cnt_A*100*A <= F:
  cnt_B=0
  while cnt_B*100*B <= F-cnt_A*100*A:
    cnt_C=0
    while cnt_C*C <= F-cnt_A*100*A-cnt_B*100*B:
      cnt_D=0
      while cnt_D*D <= F-cnt_A*100*A-cnt_B*100*B-cnt_C*C:
        if (cnt_A*A+cnt_B*B)*E >= cnt_C*C+cnt_D*D >0:
          if max_noudo < 100*(cnt_C*C+cnt_D*D)/(cnt_A*A+cnt_B*B):
            max_noudo = 100*(cnt_C*C+cnt_D*D)/(cnt_A*A+cnt_B*B)
            water=cnt_A*A*100+cnt_B*B*100+cnt_C*C+cnt_D*D
            sugar=cnt_C*C+cnt_D*D
        cnt_D+=1
      cnt_C+=1
    cnt_B+=1
  cnt_A+=1
 
print(water,sugar)

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

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
ansS = 0
ansT = 0
rate = -1
for a in range(F // (A*100)+1):
    di_a = F - A*a*100
    for b in range(di_a // (B*100) + 1):
        di_b = di_a - B*b*100
        for c in range(di_b//C+1):
            di_c = di_b - c*C
            for d in range(di_c //D+1):
                if (a+b != 0 and E*(a*A+b*B) >= c*C+d*D):
                    total = 100*(A*a+B*b)+c*C+d*D
                    sugers = c*C+d*D
                    if(rate < sugers/total and total <= F):
                        rate = sugers/total
                        ansT = total
                        ansS = sugers

print(ansT, ansS)

Solution (Python):
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
e = int(s[4]);
f = int(s[5]);
ans = 0;
ans_w = 100*a;
ans_s = 0;
for i in range(0,f,100*a) :
	for j in range(0,f,100*b) :
		
			for k in range(0, f - i - j,c) :
				for l in range(0, f - i - j,d) :
					if i != 0 or j != 0 or k != 0 or l != 0 :
						
						if i+j+k+l <= f and  k + l <= e * ( i + j )//100 :
							if 100*( k + l )/( i + j + k + l ) > ans :
								ans = 100 *( k + l )/( i + j + k + l );
								ans_w = i + j;
								ans_s = k + l;
print(ans_w+ans_s,ans_s);

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

dil=0
ans=(0,0)
for i in range(F//(A*100)+1):
    F_remainA=F-i*A*100
    for j in range(F_remainA//B*100+1):
        F_remainB=F_remainA-j*B*100   
        for k in range(F_remainB//C+1):
            F_remainC=F_remainB-k*C
            for l in range(F_remainC//D+1):
                if i+j!=0 and k+l!=0:
                    if (k*C+l*D)/(i*A*100+j*B*100+k*C+l*D) > dil and (k*C+l*D)/(i*A+j*B)<=E:
                        dil=(k*C+l*D)/(i*A*100+j*B*100+k*C+l*D)
                        ans=(100*(i*A+j*B)+k*C+l*D, k*C+l*D)

if dil==0:
    print(min(A,B)*100, 0)
else:
    print(*ans)

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

A, B, C, D, E, F = nl()

max_density = -1
max_total = 0
max_sugar = 0
for i in range(F // 100):
    for j in range(F // 100):
        if i == 0 and j == 0:
            continue

        water = 100*A*i + 100*B*j
        if water > F:
            break

        left = F - water
        sugar_limit = min((A*i+B*j)*E, F - water)

        msugar = 0
        for k in range(sugar_limit // C + 1):
            for l in range(sugar_limit // D + 1):
                sugar = C * k + D * l
                if sugar > sugar_limit:
                    break
                if sugar > msugar:
                    msugar = sugar

        density = 100 * msugar / (msugar + water)
        if density > max_density:
            max_density = density
            max_total = msugar + water
            max_sugar = msugar

print(max_total, max_sugar)

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

ma_per = -1
ma_w = -1
ma_s = -1

for aa in range(31):
    for bb in range(31):
        for cc in range(101):
            for dd in range(101):
                w = 100 * aa * a + 100 * bb * b
                s = cc * c + dd * d
                if (w + s) > f:
                    break
                if s > (w * e / 100):
                    break
                if w+s == 0:
                    break
                per = 100 * s / (w + s)
                if per > ma_per:
                    ma_per = per
                    ma_w = w
                    ma_s = s

print("{0} {1}".format(ma_w + ma_s, ma_s))

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100
water = []
sugar = []
for i in range(1 + f // a):
    for j in range(1 + f // b):
        if i * a + j * b <= f:
            water.append(i * a + j * b)
for i in range(1 + f // c):
    for j in range(1 + f // d):
        if i * c + j * d <= f:
            sugar.append(i * c + j * d)
max_sugar_percent = 0
max_sugarwater = 0
max_sugar = 0
water.sort()
sugar.sort()
for w in water:
    for s in sugar:
        if w + s > f:
            break
        if s > e * w / 100:
            break
        sugar_percent = w and (100 * s) / (w + s)
        if sugar_percent >= max_sugar_percent:
            max_sugar_percent = sugar_percent
            max_sugar = s
            max_sugarwater = w + s
print(max_sugarwater, max_sugar)

Solution (Python):
a, b, c, d, e, f = [int(i) for i in input().split()]
max_density = 0.0
water = 0
sugar = 0
for i_1 in range(f//(a*100)+1):
    for i_2 in range((f-100*a*i_1)//(b*100)+1):
        for i_3 in range(min(((i_1*a+i_2*b)*e)//c , (f-(i_1*100*a+i_2*100*b))//c)+1):
            i_4 = min((((i_1*a+i_2*b)*e)-i_3*c)//d , (f-(i_1*100*a+i_2*100*b+i_3*c))//d)
            if i_1 == 0 and i_2 == 0:
                break
            if (i_3*c + i_4*d)/(i_1*100*a+i_2*100*b+i_3*c + i_4*d) >= max_density:
                max_density = (i_3*c + i_4*d)/(i_1*100*a+i_2*100*b+i_3*c + i_4*d)
                water = i_1*100*a+i_2*100*b
                sugar = i_3*c + i_4*d
print(water+sugar, sugar)

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


ans = (0, 0, 0)


for i in range(0, f // (100 * a) + 1):
    for j in range(0, f // (100 * b) + 1):
        if i == 0 and j == 0:
            continue

        
        waterV = 100 * a * i + 100 * b * j
        if waterV > f:
            break

        
        leftVolume = f - waterV
        
        satouMax = min((a*i + b*j) * e, leftVolume)  

        
        sMax = 0
        for si in range(0, satouMax // c + 1):
            blnOk = False
            for sj in range(0, satouMax // d + 1):
                satou = c * si + d * sj
                if satou == satouMax:
                    sMax = satou
                    blnOk = True
                    break
                if satou > satouMax:
                    break
                sMax = max(sMax, satou)

            if blnOk:
                break

        
        noudo = 100 * sMax / (waterV + sMax)

        if ans[0] <= noudo:
            ans = (noudo, waterV+sMax, sMax)

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