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())
mxc = 0
ans = (min(100*A,100*B),0)
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                w = 100*A*i + 100*B*j
                s = C*k + D*l
                if s > E*w/100 or w+s > F or w == 0:
                    break
                if 100*s/(s+w) > mxc:
                    mxc = 100*s/(s+w)
                    ans = (s+w,s)
print(" ".join(map(str,ans)))

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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

A, B, C, D, E, F = list(map(int, sys.stdin.readline().split()))

waters = set()
for a, b in itertools.product(range(31), repeat=2):
    w = A * a * 100 + B * b * 100
    if w <= F:
        waters.add(w)
waters.remove(0)
waters = list(waters)
waters.sort()

dp = [0] * (F + 1)
dp[0] = 1
for i in range(F + 1):
    if i + C < len(dp):
        dp[i + C] |= dp[i]
    if i + D < len(dp):
        dp[i + D] |= dp[i]
sugars = [i for i, s in enumerate(dp) if s]
sugars.sort()

ans_w = waters[0]
ans_s = 0
msw = 0
s = 0
for w in waters:
    while s < len(sugars) and sugars[s] * 100 <= E * w and w + sugars[s] <= F:
        s += 1
    if s - 1 < 0:
        continue
    sw = sugars[s - 1] / (w + sugars[s - 1])
    if sw > msw:
        msw = sw
        ans_w = w
        ans_s = sugars[s - 1]
print(ans_w + ans_s, ans_s)

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


cap = e / (100 + e)
max_noudo = 0
sugar_ans, water_ans = 0, 0
for i in range(f//(100*a)+1):
    for j in range((f - (100 * a * i)) // (100 * b) + 1):
        water = 100 * (i * a + j * b)
        for k in range(((i * a + j * b)*e)//c+1):
            for l in range(((i * a + j * b)*e - k*c)//d+1):
                sugar = k * c + l * d
                if f < water + sugar or water == 0:
                    continue
                else:
                    noudo = sugar / (water + sugar)
                    if max_noudo <= noudo <= cap:
                        max_noudo = noudo
                        sugar_ans = sugar
                        water_ans = water
print(water_ans+sugar_ans, sugar_ans)

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


cap = e / (100 + e)
max_noudo = 0
sugar_ans, water_ans = 0, 0
for i in range(f//(100*a)+1):
    for j in range((f - (100 * a * i)) // (100 * b) + 1):
        water = 100 * (i * a + j * b)
        for k in range(((i * a + j * b)*e)//c+1):
            for l in range(((i * a + j * b)*e - k*c)//d+1):
                sugar = k * c + l * d
                if f < water + sugar or water == 0:
                    continue
                else:
                    noudo = sugar / (water + sugar)
                    if max_noudo <= noudo <= cap:
                        max_noudo = noudo
                        sugar_ans = sugar
                        water_ans = water
print(water_ans+sugar_ans, sugar_ans)

Solution (Python):


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

st = time.time()

l = list(itertools.product(range(31), repeat=2))
water = []
for i in range(len(l)):
    tmp = 0
    tmp += 100 * A * l[i][0]
    tmp += 100 * B * l[i][1]
    if tmp <= 3000:
        water.append(tmp)
l = list(itertools.product(range(1501), repeat=2))
water = list(set(water))

sugar = []
for i in range(len(l)):
    tmp = 0
    tmp += C * l[i][0]
    tmp += D * l[i][1]
    if tmp <= 1500:
        sugar.append(tmp)
sugar = list(set(sugar))




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

ans.sort(key=lambda x:x[2])



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







ed = time.time()

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

X = []
for i in range(F // (100 * A) + 1):
	for j in range((F - 100 * A * i) // (100 * B) + 1):
		X.append(100 * A * i + 100 * B * j)

Y = []
for i in range(F // C + 1):
	for j in range((F - C * i) // D + 1):
		Y.append(C * i + D * j)

concentrationMAX = 0
ans = [100 * A,0]

for i in X:
	for j in Y:
		if i + j > 0:
			if i + j <= F:
				if i // 100 * E >= j:
					if j / (i + j) > concentrationMAX:
						concentrationMAX = j / (i + j)
						ans[0] = i + j
						ans[1] = j

print(ans[0],end=' ')
print(ans[1])

Solution (Python):



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

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

A_max = int(F / (100*A))
B_max = int(F / (100*B))
AB = []

for a in range(1, A_max+1):
    for b in range(B_max+1):
        if 100*A*a + 100*B*b > F: break
        AB.append(100*A*a + 100*B*b)

AB = sorted(set(AB))
S_max = int(AB[-1] * E / 100)
C_max = int(S_max / C)
D_max = int(S_max / D)

max_ab = AB[-1]
max_cd = 0
max = 0

for ab in AB:
    S = ab * E / 100
    for c in range(C_max+1):
        for d in range(D_max+1):
            cd = C*c + D*d
            if cd > S or ab + cd > F: break
            if cd / (ab + cd) > max:
                max_ab = ab
                max_cd = cd
                max = max_cd / (max_ab + max_cd)

print(max_ab + max_cd, max_cd)

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

def sol(i):
	solmax = min((i*E)//100,F-i)
	s = []
	for i in range((solmax//C)+1):
		for j in range((solmax//D)+1):
			if C*i+D*j <= solmax:
				s.append(C*i+D*j)
	s = sorted(s)
	return s[-1]

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

water = list(set(water))
suger = []
for i in range(len(water)):
	suger.append(sol(water[i]))

con = 0
ws = 0
s = 0
for k in range(len(water)):
	if con <= suger[k]/(water[k]+suger[k]):
		con = suger[k]/(water[k]+suger[k])
		ws = (water[k]+suger[k])
		s = suger[k]

print(ws,s)

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
a_list = set([])
b_list = set([])
for i in range((f // a) + 1):
    for j in range((f // b) + 1):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.add(((a*i)+(b*j))*100)
for i in range((f // c) + 1):
    for j in range((f // d) + 1):
        if ((c*i) + (d*j)) <= f:
            b_list.add((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / aa) <= e * 0.01):
            if ans <= (bb / aa) * 100:
                ans = (bb / (aa)) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

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

maxVal = 0
ans = (100 * A, 0)
for aWater in range(0, F + 1, A * 100):
    for bWater in range(0, F + 1, B * 100):
        sumWater = aWater + bWater
        if sumWater == 0 or sumWater > F:
            continue
        maxSuger = sumWater * E // 100
        for cSuger in range(0, maxSuger + 1, C):
            for dSuger in range(0, maxSuger + 1, D):
                sumSuger = cSuger + dSuger
                if sumSuger + sumWater > F or sumSuger > maxSuger:
                    break
                if maxVal < sumSuger / (sumSuger + sumWater):
                    maxVal = sumSuger / (sumSuger + sumWater)
                    ans = (sumSuger + sumWater, sumSuger)

print(*ans)

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

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

Solution (Python):
a,b,c,d,e,f = map(int,input().split())
a,b = max(a,b),min(a,b)
c,d = max(c,d),min(c,d)
mcons = 0
ans = ""
for ia in range(f//(a*100)+1):
    for ib in range((f-ia*100*a)//(b*100)+1):
        water = a*100*ia+b*100*ib
        sglim = min(water//100*e,f-water)
        for ic in range(sglim//c+1):
            for i_d in range((sglim-c*ic)//d+1):
                if water>0:
                    suger = c*ic+d*i_d
                    cons = suger/(suger+water)
                    mcons = max(cons,mcons)
                    if mcons == cons:
                        ans = [water+suger,suger]
print(" ".join(list(map(str,ans))))

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

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

wa = []
for a in range(0,F//(A*100)+1):
    for b in range(0,F//(B*100)+1):
        w = a*A*100 + b*B*100
        if w < F and w not in wa:
            wa.append(w)
wa.remove(0)

md = 0
sw = 0
ss = 0
limit_dens = (100*E)/(100+E)
for w in wa:
    for c in range(0,F//C+1):
        for d in range(0,F//D+1):
            s = c*C + d*D
            if w + s <= F:
                d = (100*s)/(w+s)
                if d <= limit_dens:
                    if md <= d:
                        md = d
                        sw = w+s
                        ss = s
                        if d == limit_dens:
                            print(sw, ss)
                            exit()
print(sw, ss)

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

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

wa = []
for a in range(0,F//(A*100)+1):
    for b in range(0,F//(B*100)+1):
        w = a*A*100 + b*B*100
        if w < F and w not in wa:
            wa.append(w)
wa.remove(0)
sa = []
for c in range(0,F//C+1):
    for d in range(0,F//D+1):
        s = c*C + d*D
        if s < F and s not in sa:
            sa.append(s)
md = 0
sw = 0
ss = 0
limit_dens = (100*E)/(100+E)
for w in wa:
    for s in sa:
        if w + s <= F:
            d = (100*s)/(w+s)
            if d <= limit_dens:
                if md <= d:
                    md = d
                    sw = w+s
                    ss = s
                    if d == limit_dens:
                        print(sw, ss)
                        exit()
print(sw, ss)

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

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

m = 0
sw = 0
ss = 0
for a in range(1,F//(A*100)+1):
    w = a*A*100
    for b in range(0,F//(B*100)+1):
        w += b*B*100
        for c in range(0,F//C+1):
            for d in range(0,F//D+1):
                s = c*C + d*D
                dens = (100*s)/(w+s)
                limit_dens = (100*E)/(100+E)
                if w + s <= F and dens <= limit_dens:
                    if m <= (100*s)/(w+s):
                        m = (100*s)/(w+s)
                        sw = w+s
                        ss = s
                        if dens == limit_dens:
                            print(sw, ss)
                            exit()
print(sw, ss)

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

max_c = 0
max_w = 0
max_s = 0



for i in range(int((f//(100*a)+1))):
  for j in range(int((f-100*a*i)//(100*b)+1)):
    x = 100*a*i+100*b*j
    for k in range(int((f-x)//c+1)):
      for l in range(int((f-x-c*k)//d+1)):
        y = c*k+d*l
        if x+y == 0 or x+y > f:
          continue
        else:
          conc = (100*y)/(x+y)
          
          if max_c <= conc and y <= (x*e)/100:
            max_c = conc
            max_w = x
            max_s = y
print(int(max_w+max_s), int(max_s))

Solution (Python):
a,b,c,d,e,f = map(int,input().split())
can = []
for ai in range(31):
  for bi in range(31):
    if ai == bi == 0:
      continue
    whole = ( ai * a + bi * b ) * 100
    sugarmax = ( ai * a + bi * b ) * e
    sugarrest = sugarmax
    
    juicerest = f - whole
    ci = 0
    while True:
      if juicerest < 0 or sugarrest < 0:
        break
      di = min( sugarrest , juicerest ) // d
      can.append([(ci*c+di*d)/(whole+di*d),whole+di*d,ci*c+di*d,ai,bi,ci,di,sugarrest,juicerest])
      whole += c
      sugarrest -= c
      juicerest -= c
      ci += 1
can.sort()

print(str(can[-1][1]) + ' ' + str(can[-1][2]))

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

for a in range(F//(100*A)+1):
    for b in range((F-a*100*A)//(100*B)+1):
        water = a * 100 * A + b * 100 * B
        if water == 0:
            continue

        for c in range((a*A+b*B)*E//C+1):
            for d in range(((a*A+b*B)*E-c*C)//D+1):
                sugar = c * C + d * D
                if sugar + water > F:
                    continue
                conc = 100 * sugar / (water + sugar)
                answers[conc] = [str(water+sugar), str(sugar)]

max_conc = max(answers)
print(' '.join(answers[max_conc]))

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

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

"""
100gあたりEgとける

ABCDは何回でも行える
A,Bは100A, 100B

Fg以内で砂糖を溶け残らせてはいけない
水全体と砂糖の量を求める

濃度は100b/(a+b)

砂糖を細かく追加して、溶け残らないようにする？
2, 5あれば、4,5にできるので、組み合わせを全部試す？
ビーカー量が200gで、溶ける量が15gなら、最大でも30gまでしか溶けない
10, 20なら、10, 10, 10,と10, 20の組み合わせが考えられる
Cの最大回数とDの最大回数を求める
それぞれの量の組み合わせをすべて試す
例えば10回、10回なら、0,0/1,0/2,0...とすべて試す
"""
max_sugar_amount = int(F//(100+E)*E)
max_C_times = int(max_sugar_amount // C)
max_D_times = int(max_sugar_amount // D)


ans_sugar = 0
ans_water = 0
ans_density = 0
def check_density(sugar, water, new_sugar, new_water):
    if water + sugar == 0:
        return True 
    density = (100*sugar) / (water+sugar)
    new_density = (100*new_sugar) / (new_water + new_sugar)
    return density < new_density


for i in range(0, max_C_times+1):
    
    if max_D_times == 0:
        sugar_amount = i*C
        if sugar_amount > max_sugar_amount:
            break
        else:
            
            
            water_limit = F - sugar_amount
            min_water_amount = sugar_amount / E * 100
            
            max_A_times = int(water_limit // (A*100))
            max_B_times = int(water_limit // (B*100))
            
            for k in range(1, max_A_times+1):
                if max_B_times == 0:
                    
                    water = k*100*A
                    if water_limit >= water >= min_water_amount:
                        
                        if check_density(ans_sugar, ans_water, sugar_amount, water):
                            ans_sugar = sugar_amount
                            ans_water = water
                else:
                    for l in range(0, max_B_times+1):
                        water = k*100*A + l*100*B
                        if water_limit >= water >= min_water_amount:
                            
                            if check_density(ans_sugar, ans_water, sugar_amount, water):
                                ans_sugar = sugar_amount
                                ans_water = water

    for j in range(0, max_D_times+1):
        
        sugar_amount = i*C + j*D
        if sugar_amount > max_sugar_amount:
            break
        else:
            water_limit = F - sugar_amount
            min_water_amount = sugar_amount / E * 100
            max_A_times = int(water_limit // (A*100))
            max_B_times = int(water_limit // (B*100))
            for k in range(1, max_A_times+1):
                if max_B_times == 0:
                    water = k*100*A
                    if water_limit >= water >= min_water_amount:
                        
                        if check_density(ans_sugar, ans_water, sugar_amount, water):
                            ans_sugar = sugar_amount
                            ans_water = water
                else:
                    for l in range(max_B_times+1):
                        water = k*100*A + l*100*B
                        if water_limit >= water >= min_water_amount:
                            if check_density(ans_sugar, ans_water, sugar_amount, water):
                                ans_sugar = sugar_amount
                                ans_water = water
print(ans_water + ans_sugar, ans_sugar)

Solution (Python):

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

x,y = min(A,B),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 = A*i + B*j
        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 = sugar + water
                if sugar / total > e / (100+e):
                    break
                else:
                    if sugar / total > dens:
                        dens = sugar / total
                        x,y = total,sugar
print(x,y)

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

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

print(" ".join(map(str, res)))

Solution (Python):


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

max_a=f//100*a
max_b=f//100*b
min_ab=min(a,b)*100
max_c=(f-min_ab)//c
max_d=(f-min_ab)//d


def solve():
    cnt=0   
    ans=0   
    for i in range(max_a):
        if i*a>f:break
        for j in range(max_b):
            if i==j==0:continue
            if (i*a+j*b)*100>f:break

            for k in range(max_c):
                if (i*a+j*b)*100+k*c>f:break
                for l in range(max_d):
                    if k==l==0:continue
                    if (i*a+j*b)*100+k*c+l*d>f:break
                    w=(i*a+j*b)*100
                    s=k*c+l*d
                    D=s/w
                    if D>e/100:break
                    if cnt<D:
                        ans=(w+s,s)
                        cnt=D
                    if D==e/100:
                        return ans
    return ans
ans=solve()
if ans==0:
    print(min(a,b)*100,0)
else:print(*ans)

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

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

    answer_sugarwater = -1
    answer_sugar = -1
    max_strength = -1

    for a in range(0,F//(100*A)+1):
        for b in range(0,(F-a*A)//(100*B)+1):
            water = 100*(a*A+b*B)
            for c in range(0, (F-water)//C+1):
                for d in range(0, (F-water-c*C)//D+1):
                    if water == 0:
                        continue
                    sugar = c*C+d*D
                    strength = 100 * sugar / (water + sugar)
                    
                    if max_strength < strength and water + sugar <= F and sugar <= water/100*E:
                        max_strength = strength
                        answer_sugarwater = water + sugar
                        answer_sugar = sugar
    print(str(answer_sugarwater) + ' ' + str(answer_sugar))

Solution (Python):

import sys, math, fractions, itertools


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    L = []
    for i in range(31):
        for j in range(31):
            if 100*(A*i+B*j) <= F:
                L.append(100*(A*i+B*j))
    L.sort()

    S = []
    for i in range(101):
        for j in range(101):
            if C*i+D*j<=F:
                S.append(C*i+D*j)
    S.sort()

    mx = 0
    ans = (A*100, 0)
    for l in L:
        for s in S:
            if l != 0 or s != 0:
                if l+s<=F and l*E/100 >= s and s/(l+s) > mx:
                    mx = s/(l+s)
                    ans = (l+s, s)
    print(ans[0], ans[1])
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    D = int(next(tokens))  
    E = int(next(tokens))  
    F = int(next(tokens))  
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Solution (Python):

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

total_water_set = set()
for hund_a in range(0, f+1, 100*a):
    total_water = hund_a
    while total_water <= f:
        total_water_set.add(total_water)
        total_water += 100*b

total_water_set.remove(0)

total_sugar_set = set()
for _c in range(0, f+1, c):
    total_sugar = _c
    while total_sugar <= f:
        total_sugar_set.add(total_sugar)
        total_sugar += d

max_nodo = 0
max_sugawater_weight = min(total_water_set)
max_sugar_weight = 0
import decimal
total_water_set = list(map(decimal.Decimal,total_water_set))
total_sugar_set = list(map(decimal.Decimal,total_sugar_set))
nodo_limit = 100 * decimal.Decimal(e) / (100+decimal.Decimal(e))
for water in total_water_set:
    for sugar in total_sugar_set:
        if water + sugar <= f:
            nodo = 100 * sugar / (water + sugar)
            if nodo > max_nodo and nodo <= nodo_limit:
                max_nodo = nodo
                max_sugawater_weight = water + sugar
                max_sugar_weight = sugar
print("{} {}".format(max_sugawater_weight,max_sugar_weight))

Solution (Python):

import sys
INF = float("inf")


def solve(A: int, B: int, C: int, D: int, E: int, F: int):

    mwater = 0
    msugar = 0
    mnoudo = 0

    
    for i in range(-(-F//100)*A+1):
        
        for j in range(-(-F//100)*B + 1):
            water = 100*A*i+100*B*j
            if water > F:
                break
            
            for k in range(-(-water*E//100)//C + 1):
                if water+C*k > F:
                    break
                for l in range(-(-water*E//100)//D + 1):
                    sugar = C*k + D*l
                    if water + sugar > F:
                        break
                    if (water*E/100) < sugar:
                        break
                    if water+sugar == 0:
                        break
                    noudo = 100*sugar/(water+sugar)
                    
                    if mnoudo <= noudo:
                        mnoudo = noudo
                        mwater = water
                        msugar = sugar
    print(mwater+msugar, msugar)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    D = int(next(tokens))  
    E = int(next(tokens))  
    F = int(next(tokens))  
    solve(A, B, C, D, E, F)


if __name__ == '__main__':
    main()

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

amax = F//(100*A)
bmax = F//(100*B)

concmx =0
wholemx =0
sugarmx =0

for a in range(amax,-1,-1):
    bmax = (F-100*A*a)//B
    for b in range(bmax,-1,-1):
        cmax = (F-100*A*a-100*B*b)//C
        
        for c in range(cmax,-1,-1):
            dmax = (F-100*A*a-100*B*b-C*c)//D
            for d in range(dmax,-1,-1):
                sugar =C*c+D*d
                whole = 100*A*a+100*B*b+sugar
                if whole ==0:
                    break
                elif sugar/whole <= E/(100+E) and whole <=F:
                    if sugar/whole >= concmx:
                        concmx =sugar/whole
                        sugarmx = sugar
                        wholemx =whole
                    
                   
print(str(wholemx)+" "+str(sugarmx))

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

amax = F//(100*A)
bmax = F//(100*B)

concmx =0
wholemx =0
sugarmx =0

for a in range(amax,-1,-1):
    for b in range(bmax,-1,-1):
        cmax = (F-100*A*a-100*B*b)//C
        dmax = (F-100*A*a-100*B*b)//D
        for c in range(cmax,-1,-1):
            for d in range(dmax,-1,-1):
                sugar =C*c+D*d
                whole = 100*A*a+100*B*b+sugar
                if whole ==0:
                    break
                elif sugar/whole <= E/(100+E) and whole <=F:
                    if sugar/whole >= concmx:
                        concmx =sugar/whole
                        sugarmx = sugar
                        wholemx =whole
                    
                   
print(str(wholemx)+" "+str(sugarmx))

Solution (Python):

import sys

def main():
    a, b, c, d, e, f = map(int, input().split())
    ans = [-1, 0, 0]
    for i in range(31):
        for j in range(31):
            now_water = i * 100 * a + j * 100 * b
            if now_water == 0:
                continue
            if now_water > f:
                break
            for k in range(10000):
                for l in range(100000):
                    now_sio = k * c + l * d
                    if now_sio > (i * a + j * b) * e:
                        break
                    if now_water + now_sio > f:
                        break
                    noud = 100 * now_sio / (now_water + now_sio)
                    
                    if noud > ans[0]:
                        ans[0] = noud
                        ans[1] = now_water + now_sio
                        ans[2] = now_sio

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



if __name__ == '__main__':
    main()

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

ans = -1
sugar = 0
sugar_water = 0
for a in range(F // (A * 100) + 1):
    for b in range((F - 100 * A * a) // (B * 100) + 1):
        for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
            for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                x = a * A + b * B
                y = c * C + d * D
                if x == 0:
                    continue
                if x * E >= y and ans < (100 * y)/(x*100+y):
                    ans = (100 * y)/(x*100+y)
                    sugar = y
                    sugar_water = 100 * x + y
print(sugar_water,sugar)

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

ans = -1
sugar = 0
sugar_water = 0
for a in range(F // (A * 100) + 1):
    for b in range((F - 100 * A * a) // (B * 100) + 1):
        for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
            for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                x = a * A + b * B
                y = c * C + d * D
                if x == 0:
                    continue
                if x * E >= y and ans < (100 * y)/(x*100+y):
                    ans = (100 * y)/(x*100+y)
                    sugar = y
                    sugar_water = 100 * x + y
print(sugar_water,sugar)