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 itertools

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

WF = F//100+1

water = [False] * (WF+1+30)
sugar = [False] * (F+1+30)

water[0] = True
sugar[0] = True

for n in range(WF):
  if water[n]:
    water[n+A] = True
    water[n+B] = True
for n in range(F):
  if sugar[n]:
    sugar[n+C] = True
    sugar[n+D] = True

water = set(100*x for x in range(1,1+WF) if water[x])
sugar = set(x for x in range(1+F) if sugar[x])


ans_per = -1
for w, s in itertools.product(water, sugar):
  if w//100*E < s:
    continue
  if w+s > F:
    continue
  x = s/(w+s)
  if x > ans_per:
    ans_per = x
    ans_w = w
    ans_s = s

print(ans_w + ans_s, ans_s)

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
dp1=[0]*31
dp1[0]=1
m=0
for i in range(1,31):
    if i-A>=0:
        dp1[i]=max(dp1[i],dp1[i-A])
        m=(i)*E
    if i-B>=0:
        dp1[i]=max(dp1[i],dp1[i-B])
        m=(i)*E
dp2=[0]*(1+m)
dp2[0]=1
for i in range(m+1):
    if i-C>=0:
        dp2[i]=max(dp2[i],dp2[i-C])
    if i-D>=0:
        dp2[i]=max(dp2[i],dp2[i-D])
ans=0
w=0
s=0
for i in range(1,31):
    if dp1[i]==0:
        continue
    for j in range(1+m):
        if dp2[j]==0:
            continue
        if j<=i*E and i*100+j<=F:
            if ans<100*j/(i*100+j):
                ans=100*j/(i*100+j)
                w=100*i
                s=j
if s==0:
    print(min(A,B)*100,0)
    quit()
print(w+s,s)

Solution (Python):
def main():
    A, B, C, D, E, F = map(int, input().split())
    xl = []
    yl = []
    for i in range(31):
        for j in range(31):
            x = 100 * A * i + 100 * B * j
            if F >= x and x > 0 and x not in xl:
                xl.append(x)
    for i in range(F):
        for j in range(F):
            y = C * i + D * j
            if F >= y and y > 0 and y not in yl:
                yl.append(y)
    ax = 3001
    ay = 0
    for x in xl:
        for y in yl:
            if F >= x + y and E / (E + 100) >= y / (x + y) and y / (x + y) > ay / (ax + ay):
                ax = x
                ay = y
    if ax == 3001:
        print(100 * A, 0, end=' ')
    else:
        print(ax + ay, ay, end=' ')


main()

Solution (Python):

A,B,C,D,E,F=map(int,input().split())
density=0
Ans1=0
Ans2=0
water=set() 
sugar=set()

bm=F//(100*B)
for i in range(bm+1):
    rw=F-100*i*B
    am=rw//(100*A)
    for j in range(am+1):
        water.add(100*i*B+100*j*A)

dm=F//D
for i in range(dm+1):
    rs=F-i*D
    cm=rs//C
    for j in range(cm+1):
        sugar.add(i*D+j*C)
sugar=sorted(sugar)
water=sorted(water)
for s in sugar:
    for w in water:
        if w/100*E>=s and s+w<=F and s+w!=0:
            den=s/(s+w)
            if den>=density:
                density=den
                Ans1=s+w
                Ans2=s
            else:
                break
print(Ans1,Ans2)

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

water = 0
sugar = 0
density = 0

for i in range(31):
    for j in range(31):
        w = 100 * a * i + 100 * b * j
        for k in range(101):
            for l in range(101):
                s = c * k + d * l
                if w == 0:
                    break
                elif w + s > f:
                    break
                else:
                    if water == 0:
                        water = w + s
                        sugar = s
                        density = s/(w+s)
                    
                    if density < s/(w+s) <= m_dens:
                        water = w + s
                        sugar = s
                        density = s/(w+s)

print(water, sugar)

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

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


def concentration(water, suger):
    if water * E/100 < suger or water + suger == 0:
        return 0
    return (100 * suger/(water + suger))

lst_w = []
limit_w = (F+A*100-1)//(A*100)
for i in range(limit_w):
    for j in range(limit_w):
        if 100 * (A * i + B * j) <= F:
            lst_w += [100 * (A * i + B * j)]

lst_s = []
limit_s = (F+C-1)//C
for i in range(limit_s):
    for j in range(limit_s):
        if C* i + D * j <= F:
            lst_s += [C * i + D * j]



set_w = set(lst_w)
set_s = set(lst_s)




ans = 0
ans_total = 0
ans_suger = 0
for water in set_w:
    for suger in set_s:
        if water + suger <= F:
            a = concentration(water, suger)
            if ans < a:
                ans = a
                ans_total = water + suger
                ans_suger = suger
            if ans == 50:
                print (ans_total, ans_suger)
                sys.exit()

if ans == 0:
    print (A * 100, 0)
else:
    print (ans_total, ans_suger)

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


def concentration(water, suger):
    if water * E/100 < suger or water + suger == 0:
        return 0
    return (100 * suger/(water + suger))

lst_w = []
limit_w = (F+A*100-1)//(A*100)
for i in range(limit_w):
    for j in range(limit_w):
        if 100 * (A * i + B * j) <= F:
            lst_w += [100 * (A * i + B * j)]

lst_s = []
limit_s = (F+C-1)//C
for i in range(limit_s):
    for j in range(limit_s):
        if C* i + D * j <= F:
            lst_s += [C * i + D * j]



set_w = set(lst_w)
set_s = set(lst_s)




ans = 0
ans_total = 0
ans_suger = 0
for water in set_w:
    for suger in set_s:
        if water + suger <= F:
            a = concentration(water, suger)
            if ans < a:
                ans = a
                ans_total = water + suger
                ans_suger = suger
            if ans == 50:
                print (ans_total, ans_suger)
                sys.exit()

if ans == 0:
    print (A * 100, 0)
else:
    print (ans_total, ans_suger)

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

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

water = 0
sugar = 0
density = 0

for i in range(31):
    for j in range(31):
        w = 100 * a * i + 100 * b * j
        for k in range(101):
            for l in range(101):
                s = c * k + d * l
                if w == 0:
                    break
                elif w + s > f:
                    break
                else:
                    if water == 0:
                        water = w + s
                        sugar = s
                        density = s/(w+s)
                    
                    if density < s/(w+s) <= m_dens:
                        water = w + s
                        sugar = s
                        density = s/(w+s)

print(water, sugar)

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_sugar_water = 0
max_sugar = 0
water.sort()
sugar.sort()
for i in water:
    for j in sugar:
        if i + j > F:
            break
        if j > E * i / 100:
            break
        sugar_percent = i and (100 * j) / (i + j)
        if sugar_percent >= max_sugar_percent:
            max_sugar_percent = sugar_percent
            max_sugar = j
            max_sugar_water = i + j
print(max_sugar_water, max_sugar)

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):
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor, mul

import sys


def inpl(): return list(map(int, input().split()))
A, B, C, D, E, F = inpl()
waters = [100*A*a + 100*B*b for a in range(30//A + 1) for b in range((30-A*a)//B + 1)]
sugars = [C*c + D*d for c in range(3000//C + 1) for d in range((3000-C*c)//D + 1)]

waters = sorted(set(waters))[1:]
sugars = sorted(set(sugars))


def check(m):
    if m > E:
        return False, None, None
    for water in waters:
        sugar_ix = bisect_left(sugars, m*water/(100-m))
        if (sugar_ix == len(sugars)):
            continue
        sugar = sugars[sugar_ix]
        if sugar + water <= F and sugar <= water*E//100:
            return True, sugar, water
    else:
        return False, None, None

OK = 0
NG = E + 1

for _ in range(1000):
    mid = (OK+NG)/2
    if check(mid)[0]:
        OK = mid
    else:
        NG = mid

_, sugar, water = check(OK)
print(sugar+water, sugar)

Solution (Python):
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor, mul

import sys


def inpl(): return list(map(int, input().split()))
A, B, C, D, E, F = inpl()
waters = [100*A*a + 100*B*b for a in range(30//A + 1) for b in range((30-A*a)//B + 1)]
sugars = [C*c + D*d for c in range(3000//C + 1) for d in range((3000-C*c)//D + 1)]

waters = sorted(set(waters))[1:]
sugars = sorted(set(sugars))


def check(m):
    if m > E:
        return False, None, None
    for water in waters:
        sugar_ix = bisect_left(sugars, m*water/(100-m))
        if (sugar_ix == len(sugars)):
            continue
        sugar = sugars[sugar_ix]
        if sugar + water <= F and sugar <= water*E//100:
            return True, sugar, water
    else:
        return False, None, None

OK = 0
NG = E + 1

for _ in range(1000):
    mid = (OK+NG)/2
    if check(mid)[0]:
        OK = mid
    else:
        NG = mid

_, sugar, water = check(OK)
print(sugar+water, sugar)

Solution (Python):
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor, mul

import sys


def inpl(): return list(map(int, input().split()))
A, B, C, D, E, F = inpl()
waters = [100*A*a + 100*B*b for a in range(30//A + 1) for b in range((30-A*a)//B + 1)]
sugars = [C*c + D*d for c in range(3000//C + 1) for d in range((3000-C*c)//D + 1)]

waters = sorted(set(waters))[1:]
sugars = sorted(set(sugars))


def check(m):
    if m > E:
        return False, None, None
    for water in waters:
        sugar_ix = bisect_left(sugars, m*water/(100-m))
        if (sugar_ix == len(sugars)):
            continue
        sugar = sugars[sugar_ix]
        if sugar + water <= F and sugar <= water*E//100:
            return True, sugar, water
    else:
        return False, None, None

OK = 0
NG = E + 1

for _ in range(1000):
    mid = (OK+NG)/2
    if check(mid)[0]:
        OK = mid
    else:
        NG = mid

_, sugar, water = check(OK)
print(sugar+water, sugar)

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

sugar_water = -1
sugar = -1
concentration = -1

for i in range(F//(A*100)+1):
    for j in range((F-A*100*i)//(B*100)+1):
        for k in range((F-A*i*100-B*100*j)//C+1):
            for l in range((F-A*i*100-B*100*j-C*k)//D+1):
                x = i * A + j * B
                y = k * C + l * D
                if x == 0:
                    continue
                if x * E >= y and concentration < (100 * y)/(x*100+y):
                    sugar_water = 100 * x + y
                    sugar = y
                    concentration = (100 * y)/(x*100+y)

print(sugar_water,sugar)

Solution (Python):
import math
a,b,c,d,e,f=map(int,input().split())
m_suger=f*e/(100+e)
water=set()
w=math.floor(f/100/a)*a
water.add(w)
f_=f//100
while(1):
     w-=a
     if w<0:
          break
     w_=w
     while(w_<=f_):
          water.add(w_)
          w_+=b
water.remove(0)
m_rate=0
m_content=[0,0]
for w in water:
     res=f-w*100
     m_suger=min(w*e,res)
     s=math.floor(m_suger/c)*c
     while(1):
          if s<=m_suger:
               rate=s/(w+s)
               if rate>=m_rate:
                    m_rate=rate
                    m_content=[w,s]
          s-=c
          if s<0:
               break
          s_=s
          while(s_<=m_suger):
               rate=s_/(w+s_)
               if rate>=m_rate:
                    m_rate=rate
                    m_content=[w,s_]
               s_+=d
print(m_content[0]*100+m_content[1],m_content[1])

Solution (Python):
a, b, c, d, e, f = list(map(int, input().split()))
water = []
suger = []
ans = [0, 0]
ans_max = 0
for i in range(f//100+1):
  for j in range(f//100+1):
    x = 100*(i*a+j*b)
    if x <= f and x > 0 and x not in water:
      water.append(x)
for i in range(f):
  for j in range(f):
    y = c*i + d*j
    if y <= f and y not in suger:
      suger.append(y)
ans[0] = water[0]
for i in water:
  if i == 0:
      continue
  for j in suger:
    if (i+j <= f) and (i*e >= 100*j):
      percent = (100*j)/(i+j)
      if ans_max < percent:
        ans_max = percent
        ans = [i, j]
print(sum(ans), ans[1])

Solution (Python):
a,b,c,d,e,f = map(int, input().split())
ans = [-1,0,0]
for i in range(f//(a*100)+1):
  for j in range((f-a*100*i)//(b*100)+1):
    for k in range((f-a*i*100-b*j*100)//c+1):
      for l in range((f-a*i*100-b*j*100-c*k)//d+1):
        w = i*a+j*b
        s = k*c+l*d
        if w == 0:
          continue
        if w*e >= s and ans[0] < s/(w*100+s):
          ans = [s/(w*100+s),w*100+s,s]
print(ans[1],ans[2])

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

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

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

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

Solution (Python):
from collections import deque
import bisect

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

operation_water = [100*A, 100*B]
operation_sugar = [C, D]
water_lst = []
sugar_lst = [0]

def bfs_water():
    dq = deque()
    dq.append(0)
    while dq:
        water = dq.popleft()
        for add_water in operation_water:
            new_water = water + add_water
            if new_water <= F and new_water not in water_lst:
            	dq.append(new_water)
            	water_lst.append(new_water)
            
def bfs_sugar():
    dq = deque()
    dq.append(0)
    while dq:
        sugar = dq.popleft()
        for add_sugar in operation_sugar:
            new_sugar = sugar + add_sugar
            if new_sugar <= F/2 and new_sugar not in sugar_lst:
            	dq.append(new_sugar)
            	sugar_lst.append(new_sugar)

bfs_water()
bfs_sugar()
sugar_lst.sort()

concentration = []
for i in range(len(water_lst)):
  idx_maxmelt = bisect.bisect_right(sugar_lst, min(water_lst[i]/100*E, F-water_lst[i]))
  sugar_maxmelt = sugar_lst[idx_maxmelt-1]
  concentration.append((water_lst[i]+sugar_maxmelt, sugar_maxmelt, sugar_maxmelt/(water_lst[i]+sugar_maxmelt)))

max_concentration = sorted(concentration, key=lambda x:x[2], reverse=True)[0]
ans_weight = int(max_concentration[0])
ans_sugar = int(max_concentration[1])
print(ans_weight, ans_sugar)

Solution (Python):
w1, w2, s1, s2, sp, l = map(int, input().split())
w1 *= 100
w2 *= 100

ws = set()
for i1 in range(l // w1 + 1):
    for i2 in range(l // w2 + 1):
        if i1 * w1 + i2 * w2 <= l:
            ws.add(i1 * w1 + i2 * w2)


ss = set()
for i1 in range((l * sp // 100) // s1 + 1):
    for i2 in range((l * sp // 100) // s2 + 1):
        if i1 * s1 + i2 * s2 <= l * sp / 100:
            ss.add(i1 * s1 + i2 * s2)


maxd, maxws, maxs = 0, 0, 0
for w in ws:
    for s in ss:
        if w + s > l or w == 0 or s > w * sp / 100:
            continue

        d = s / (w + s)
        if d >= maxd:
            maxd = d
            maxws = w + s
            maxs = s

print(maxws, maxs)

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
water=set({})
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        if 100*A*i + 100*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])

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
max_=0
ans=[100*A,0]
for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        for k in range((F-100*A*i-100*B*j)//C+1):
            a=E/(100+E)
            bunshi=100*A*i+100*B*j+C*k
            l=min((F-bunshi)//D,(a*bunshi-C*k)//((1-a)*D))
            if bunshi+D*l==0 or l<0:
                pass
            elif bunshi+D*l <= F and (C*k+D*l)*(100+E)<=E*(bunshi+D*l):
                if max_*(bunshi+D*l)<(C*k+D*l):
                    max_ = (C*k+D*l)/(bunshi+D*l)
                    ans = [bunshi+D*l,C*k+D*l]
            if bunshi+D*(l+1)==0 or l<0:
                pass
            elif bunshi+D*(l+1) <= F and (C*k+D*(l+1))*(100+E)<=E*(bunshi+D*(l+1)):
                if max_*(bunshi+D*(l+1))<(C*k+D*(l+1)):
                    max_ = (C*k+D*(l+1))/(bunshi+D*(l+1))
                    ans = [bunshi+D*(l+1),C*k+D*(l+1)]   
print(int(ans[0]),int(ans[1]))

Solution (Python):


a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100


x, y = min(a, b) * 100, 0
dens = y / x



for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        water = i * A + j * B
        rest = f - water
        for k in range(rest // c + 1):
            for l in range((rest - c * k) // d + 1):
                sugar = c * k + d * l
                total = water + sugar

                if sugar / total > e / (e + 100):  
                    break
                else:
                    if sugar / total > dens:
                        dens = sugar / total
                        x, y = total, sugar
print(x, y)

Solution (Python):


a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100



x, y = min(a, b) * 100, 0
dens = y / x



for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        water = i * A + j * B
        rest = f - water
        for k in range(rest // c + 1):
            for l in range((rest - c * k) // d + 1):


                sugar = c * k + d * l
                total = water + sugar

                if sugar / total > e / (e + 100):  
                    break
                else:
                    if sugar / total > dens:
                        dens = sugar / total
                        x, y = total, sugar
print(x, y)

Solution (Python):
import sys
sys.setrecursionlimit(100000000)
A,B,C,D,E,F = [int(x) for x in input().split()]

x = []
y = []
ans_max = 0
ans = [0,0]

for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*(A*i+B*j)
        if(water<=F and not water in x and water!=0):
            x.append(water)

ans[0]=x[0]

for i in range(F):
    for j in range(F):
        salt = C*i+D*j
        if(salt<=F and not salt in y):
            y.append(salt)

for i in x:
    for j in y:
        if(i==0):
            continue
        elif(100*j <= i*E and i+j <= F):
            percent = 100*j/(i+j)
            if(ans_max < percent):
                ans_max = percent
                ans = [i,j]

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

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
density = 0
for water_a in range(0,3001,a * 100):
    for water_b in range(0,3001,b * 100):
        if water_a + water_b > f:
            break
        for suger_c in range(0,3001,c):
            if water_a + water_b + suger_c > f:
                break
            for suger_d in range(0,3001,d):
                if water_a + water_b + suger_c + suger_d > f:
                    break
                if e * (water_a + water_b) - 100 * (suger_c + suger_d) < 0:
                    break
                water = water_a + water_b
                suger = suger_c + suger_d
                if water + suger == 0:
                    break
                if 1 >= suger / (water + suger) >= density:
                    sugerwater = water + suger
                    meltsuger = suger
                    density = suger / (water + suger)
print(sugerwater, meltsuger)

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

for a in range(0, F+1, 100):
    a *= A
    for b in range(0, F+1, 100):
        b *= B
        water = a+b
        if water == 0 or water > F:
            break
        limit = water/100 * E

        for c in range(100):
            c *= C
            if c > limit or water+c > F:
                break

            for d in range(100):
                sugar = c + d*D
                if sugar > limit or water+sugar > F:
                    break
                tmp = 0
                if sugar != 0:
                    tmp = 100*sugar / (water+sugar)
                if tmp >= conc:
                    conc = tmp
                    W = water
                    S = sugar

print(W+S, S)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water = set()
sugar = set()
sugar_water = []

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.add(100 * A * i + 100 * B * j)

for i in range(F // C + 1):
    for j in range(F // D + 1):
        if C * i + D * j <= F:
            sugar.add(C * i + D * j)

for i in water:
    for j in sugar:
        if 0 < i + j <= F and j / (i + j) <= E / (100 + E):
            sugar_water.append([i + j, j])

max_sugar_water = max(sugar_water, key=lambda x: x[1] / x[0])
print("{} {}".format(max_sugar_water[0], max_sugar_water[1]))

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
water=[]
for i in range(1+30//a):
  for j in range(1+30//b):
    hoge=a*i*100+b*j*100
    if(hoge<=f):
      water.append(hoge)
water=list(set(water))
      
sugar=[]
for i in range(1+3000//c):
  for j in range(1+3000//d):
    hoge=c*i+d*j
    if(hoge<=f):
      sugar.append(hoge)
sugar=list(set(sugar))

node_max=0
water_max=0
sugar_max=0
for i in range(len(water)):
  for j in range(len(sugar)):
    if(water[i]+sugar[j]<=f):
      if(sugar[j]==0):
        node=0
      else:
        node=sugar[j]/(water[i]+sugar[j])
      if(node_max<=node and e*water[i]//100>=sugar[j]):
        water_max=water[i]
        sugar_max=sugar[j]
        node_max=node

print(water_max+sugar_max,sugar_max)

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

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

dens=0
a=F//100//A
b=F//100//B
c=F//C
d=F//D
for i in range(a+1):
  for j in range(b+1):
    waterA=100*i*A
    waterAB=waterA+100*j*B
    if  waterA<= F and 0 < waterAB <= F:
      for k in range(c+1):
        for l in range(d+1):
          if waterAB+k*C+l*D <= F:
            if k*C+l*D <= (i*A+j*B)*E:
              if dens < (k*C+l*D)/(waterAB+k*C+l*D):
                dens=(k*C+l*D)/(waterAB+k*C+l*D)
                max1=waterAB+k*C+l*D
                max2=k*C+l*D
            else:
              max3=waterAB
              max4=0
if dens>0:
  print(max1,max2)
else:
  print(max3,max4)

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

dens=0
for a in range(30+1):
  for b in range(30+1):
    waterA=100*a*A
    waterAB=waterA+100*b*B
    if  waterA<= F and 0 < waterAB <= F:
      for c in range(100+1):
        for d in range(100+1):
          if waterAB+c*C+d*D <= F:
            if c*C+d*D <= (a*A+b*B)*E:
              if dens < (c*C+d*D)/(waterAB+c*C+d*D):
                dens=(c*C+d*D)/(waterAB+c*C+d*D)
                max1=waterAB+c*C+d*D
                max2=c*C+d*D
            else:
              max3=waterAB
              max4=0
if dens>0:
  print(max1,max2)
else:
  print(max3,max4)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
con = 0
sugar_water = 0
sugar = 0
for a in range(31):
    for b in range(31):
        if not a == b == 0 and a*A*100 + b*B*100 <= F:
            for c in range(int((F - a*A*100 + b*B*100) / C) + 1):
                for d in range(int((F - a*A*100 + b*B*100 + c*C) / D) + 1):
                    if 100*(A*a+B*b)+C*c+D*d <= F:
                        if (c*C+d*D)/(100*a*A+100*b*B+c*C+d*D) <= E/(100+E):
                            if con <= 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D)):
                                con = 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D))
                                sugar = c*C+d*D
                                sugar_water = 100*a*A+100*b*B+c*C+d*D
print(sugar_water, sugar)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
con = 0
sugar_water = 0
sugar = 0
for a in range(int(F / 100 / A) + 1):
    for b in range(int((F - a * 100 * A)/ 100 / B) + 1):
        if not a == b == 0:
            for c in range(int((a*A+b*B)*E/C)+1):
                for d in range(int(((a*A+b*B)*E-c*C)/D)+1):
                    if 100*(A*a+B*b)+C*c+D*d <= F:
                        if con <= 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D)):
                            con = 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D))
                            sugar = c*C+d*D
                            sugar_water = 100*a*A+100*b*B+c*C+d*D
print(sugar_water, sugar)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
ans=[100*a,0]
for i in range(f//(100*a)+1):
  for j in range((f-100*a*i)//(100*b)+1):
    for k in range(f//c+1):
      if i==0 and j==0:
        break
      for l in range((f-c*k)//d+1):
        if 100*a*i+100*b*j+c*k+d*l>f:
          break
        elif c*k+d*l>(a*i+b*j)*e:
          break
        else:
          if (c*k+d*l)/(100*a*i+100*b*j+c*k+d*l)>ans[1]/ans[0]:
            ans=[100*a*i+100*b*j+c*k+d*l,c*k+d*l]
print(ans[0],ans[1])

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