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())
maxa = f//(100*a)

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

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

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

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

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

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



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

val = 0
ans1 = 100*A
ans2 = 0

for a in range(math.ceil(F/(100*A))+1):
    for b in range(math.ceil(F/(100*B))+1):
        for c in range(math.ceil((A*a+B*b)*E/C)+1):
            for d in range(math.ceil((A*a+B*b)*E/D)+1):
                if 100*(A*a+B*b)+C*c+D*d > F:
                    break
                if C*c+D*d > (A*a+B*b)*E:
                    break
                if A*a+B*b==0:
                    break
                if (C*c+D*d)/(A*a+B*b) > val:
                    val = (C*c+D*d)/(A*a+B*b)
                    ans1 = 100*(A*a+B*b)+C*c+D*d
                    ans2 = C*c+D*d

print(ans1, ans2)

Solution (Python):

import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, D, E, F = map(int, input().split())

        sousa1 = 1
        sousa2 = 0
        ans = (0, 100 * A, 0)
        while True:
            if sousa1 * 100 * A > F:
                break
            while True:
                water = sousa1 * 100 * A + sousa2 * 100 * B
                if water > F:
                    sousa2 = 0
                    break

                sugar_limit = water // 100 * E
                sousa3 = 0
                sousa4 = 0
                max_sugar = 0
                while True:
                    if sousa3 * C > sugar_limit:
                        break
                    while True:
                        sugar = sousa3 * C + sousa4 * D
                        if water + sugar > F or sugar > sugar_limit:
                            sousa4 = 0
                            break
                        else:
                            max_sugar = max(max_sugar, sugar)
                        sousa4 += 1
                    sousa3 += 1
                concentration = 100 * max_sugar / (water + max_sugar)
                if ans[0] < concentration:
                    ans = [concentration, water, max_sugar]
                sousa2 += 1
            sousa1 += 1

        print('{} {}'.format(sum(ans[1:]), ans[2]))



if __name__ == '__main__':
    AtCoder().main()

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

Solution (Python):


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

A=A*100
B=B*100

ans=[]
water=set()

for i in range(F//(A)+1):
    for j in range((F-A*i)//B+1):
        water.add(A*i+B*j)
water.remove(0)

ans=-1
ans_all=-1
ans_sol=-1

for item in water:
    for i in range((F-item)//(C)+1):
        if C*i/item*100>E:
            break
        j=min((F-item-C*i)//D,(item*E/100-C*i)//D)
        if (C*i+D*j)/(item+C*i+D*j)>ans:
            ans_sol=C*i+D*j
            ans_all=item+ans_sol
            ans=ans_sol/ans_all
    
print(int(ans_all),int(ans_sol))

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

lst = []

for a in range(0, F, 100*A):
    for b in range(0, F, 100*B):
        x = a + b        
        if x == 0 or x > F:
            continue
        
        for c in range(0, F, C):
            for d in range(0, F, D):
                y = c + d
                if x + y > F or 100*y/(x+y) > 100*E/(100+E):
                    break
                lst.append((100*y/(x+y), x+y, y)) 

d, t, y = max(lst)
print(t, y)

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

result = [0, 0]
noude = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                water = a * 100 * i + b * 100 * j
                sugar = c * k + d * l
                if water == 0 or water + sugar > f:
                    break
                if (water / 100) * e >= sugar and noude < (100 * sugar) / (water + sugar):
                    noude = (100 * sugar) / (water + sugar)
                    result = [water + sugar, sugar]

if result[1] == 0:
    print(a * 100, 0)
else:
    print(result[0], result[1])

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

Solution (Python):
if __name__ == '__main__':
    A, B, C, D, E, F = map(int, input().split())
    
    mx = 0
    sugar_weight = 0
    water_weight = 0
    for a in range(F // (100 * A) + 1):
        A_w = 100 * A * a
        for b in range((F - A_w) // (100 * B) + 1):
            B_w = 100 * B * b
            for c in range((F - (A_w + B_w)) // C + 1):
                C_w = C * c
                for d in range((F - (A_w + B_w + C_w)) // D + 1):
                    D_w = D * d
                    if a == 0 and b == 0:
                        pass
                    elif C * c + D * d <= E * (A * a + B * b):
                        if mx <= (100 * (C_w + D_w)) / (A_w + B_w + C_w + D_w):
                            mx = (100 * (C_w + D_w)) / (A_w + B_w + C_w + D_w)
                            sugar_weight = C_w + D_w
                            water_weight = A_w + B_w + C_w + D_w

    print(water_weight, sugar_weight)

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

sugar = set()
water = set()

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

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

ans_w = 0
ans_s = 0
conc = 0
for s in sugar:
    for w in water:
        if s + w > F:
            continue
        if s > w * E / 100:
            continue
        tmp = s / (s + w) * 100
        if tmp >= conc:
            conc = tmp
            ans_w = w
            ans_s = s

print(ans_s + ans_w, ans_s)

Solution (Python):
A, B, C, D, E, limit = map(int, input().rstrip("\n").split())

target_concent = E * 100 / (100 + E)
water_vars = {(i * A + j * B) * 100 for i in range(limit // (100 * A) + 1) for j in range(limit // (100 * B) + 1) if (i * A + j * B) * 100 <= limit}
water_vars = sorted(water_vars)[1:]

ans_solution = 0
ans_sugar = 0
max_concent = 0

break_all = False

for water in water_vars:
    sugar_limit = limit - water
    sugar_vars = {i * C + j * D for i in range(sugar_limit // C + 1) for j in range(sugar_limit // D + 1) if i * C + j * D <= sugar_limit}
    sugar_vars = sorted(sugar_vars)
    for sugar in sugar_vars:
        concent = sugar * 100 / (sugar + water)
        if concent == target_concent:
            ans_solution = water + sugar
            ans_sugar = sugar
            break_all = True
            break
        elif max_concent <= concent < target_concent:
            ans_solution = water + sugar
            ans_sugar = sugar
            max_concent = concent
        elif concent > target_concent:
            break
    if break_all:
        break

print(ans_solution, ans_sugar)

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
max_a = f // (100*a)
max_b = f // (100*b)
max_c = f // c
max_d = f // d
wat = []
sug = []
for i in range(max_a + 1):
    for j in range(max_b + 1):
        w = 100 * a * i + 100 * b * j
        if w <= f and w > 0:
            wat.append(w)
for i in range(max_c + 1):
    for j in range(max_d + 1):
        s = c*i + d*j
        if s < f:
            sug.append(s)
ans = 0
for x in wat:
    for y in sug:
        if x + y <= f and y <= e * x / 100:
            if ans <= 100 * y / (x + y):
                ans =  100 * y / (x + y)
                out = [x+y, y]
print(*out)

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

Solution (Python):
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c, d, e, f = na()
m = f // (100 * a)
n = f // c
wli = []
sli = []
for i in range(m+1):
    for j in range(m+1):
        x = 100 * a * i + 100 * b * j
        if 0 < x <= f:
            wli.append(x)
for i in range(n):
    for j in range(n):
        y = c * i + d * j
        if y <= f:
            sli.append(y)
ans = [0, 0, 0]
for x in wli:
    for y in sli:
        if x + y <= f and 100 * y <= e * x:
            p = y * 100 / (x + y)
            if ans[2] <= p:
                ans = [x + y, y, p]
print(*ans[:2])

Solution (Python):
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c, d, e, f = na()
m = f // (100 * a)
n = f // c
wli = []
sli = []
for i in range(m+1):
    for j in range(m+1):
        x = 100 * a * i + 100 * b * j
        if 0 < x <= f:
            wli.append(x)
for i in range(n):
    for j in range(n):
        y = c * i + d * j
        if y <= f:
            sli.append(y)
ans = [0, 0, 0]
for x in wli:
    for y in sli:
        if x + y <= f and 100 * y <= e * x:
            p = y * 100 / (x + y)
            if ans[2] <= p:
                ans = [x + y, y, p]
print(*ans[:2])

Solution (Python):

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

    WF = F//100
    water = [False] * (WF + 1)
    water[0] = True
    
    for n in range(WF + 1):
        if water[n]:
            if n+A <= WF: water[n+A] = True
            if n+B <= WF: water[n+B] = True

    sugar = [False] * (F + 1)
    sugar[0] = True
    
    for n in range(F + 1):
        if sugar[n]:
            if n+C <= F: sugar[n+C] = True
            if n+D <= F: 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]) 

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

    print(*ans)
if __name__ == '__main__':
    main()

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

    water = set()
    for a in range(0,F+1,100*A):
        for b in range(0,F+1,100*B):
            if a + b != 0 and a+b <= F:
                water.add(a+b)

    max_consist = 0
    ans = (0,0)
    for w in water:
        ab = w //100
        sugar_max = E * ab
        x = sugar_max // C
        y = sugar_max // D
        s = max(C*i + D*j for i in range(x+1) for j in range(y+1) if C*i + D*j <= sugar_max and w + C*i + D*j <= F)
        if w + s <= F:
            cur_consist = (100*s)/(w+s)
            if max_consist <= cur_consist:
                max_consist = cur_consist
                ans = (w + s,s)

    print(*ans)
if __name__ == '__main__':
    main()

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

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

    water = set()
    for a in range(0,F+1,100*A):
        for b in range(0,F+1,100*B):
            if a + b != 0 and a+b <= F:
                water.add(a+b)

    max_consist = 0
    ans = (0,0)
    for w in water:
        ab = w //100
        sugar_max = E * ab
        x = sugar_max // C
        y = sugar_max // D
        s = max(C*i + D*j for i in range(x+1) for j in range(y+1) if C*i + D*j <= sugar_max and w + C*i + D*j <= F)
        if w + s <= F:
            cur_consist = (100*s)/(w+s)
            if max_consist <= cur_consist:
                max_consist = cur_consist
                ans = (w + s,s)

    print(*ans)
if __name__ == '__main__':
    main()

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

S = [0] * 1501
for i in range(1500//c + 1):
    for j in range(1500//d + 1):
        if c * i + d * j <= 1500:
            S[c * i + d * j] = 1

S2 = [0] * 1501
t = 0
for i in range(1501):
    if S[i] == 1:
        t = i
    S2[i] = t



ans = [0, 0, 0]
for i in range(30):
    for j in range(30):
        water = i * 100 * a + j * 100 * b
        if 0 < water <= f:
            sugar_max = min(f - water, water * e * 0.01)
            sugar = S2[int(sugar_max)]
            noudo = sugar / (water + sugar)
            
            if noudo >= ans[0]:
                
                ans[0] = noudo
                ans[1] = water + sugar
                ans[2] = sugar

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

Solution (Python):


import math
w_A, w_B, s_C, s_D, limit_E, max_F = list(map(int, input().split()))





w_A_list = [w_A * x * 100 for x in range(math.floor(max_F / (w_A * 100)) + 1)]
w_B_list = [w_B * x * 100 for x in range(math.floor(max_F / (w_B * 100)) + 1)]


w_list = []
for a in w_A_list:
    for b in w_B_list:
        if a + b <= max_F:
            w_list.append(a + b)
w_list = list(set(w_list))  


s_C_list = [s_C * x  for x in range(math.floor(max_F / s_C) + 1)]
s_D_list = [s_D * x  for x in range(math.floor(max_F / s_D) + 1)]


s_list = []
for c in s_C_list:
    for d in s_D_list:
        if c + d <= max_F:
            s_list.append(c + d)
s_list = list(set(s_list))  

max_d = -float('inf')
for w in w_list:
    for s in s_list:
        limit_s = w * limit_E / 100
        if w + s <= max_F and w + s != 0 and s <= limit_s:
            d = (s / (w + s)) * 100
            if d > max_d:
                max_d = d
                ans_ws, ans_s = w + s, s

ans = ' '.join([str(ans_ws), str(ans_s)])
print(ans)

Solution (Python):
ans=[]
a,b,c,d,e,f=map(int,input().split())
for i in range(31):
	for j in range(16):
		for k in range(101):
			for l in range(51):
				if (i*a+j*b)*100+(c*k+d*l)<=f and \
				c*k+d*l<=e*(i*a+j*b):
					p=c*k+d*l
					q=p+100*(i*a+j*b)
					if 100*(i*a+j*b)!=0:
						ans.append([100*p/q,p,q])
ans.sort()
print(ans[-1][2],ans[-1][1])

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

a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
ans_total = 100*A
ans_sugar = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
      max_dens = dens
      ans_total = total
      ans_sugar = j
            
print(ans_total, ans_sugar)

Solution (Python):
import math
A,B,C,D,E,F = map(int,input().split())
water = []
for i in range(math.floor(F/(100*A))+1):
    M = 100*A*i
    while M <= F:
        if M not in water and M != 0:
            water.append(M)
        M += 100*B
def max_dens(w):
    max_s = min(F-w,w*E/100)
    max_d = 0
    for i in range(math.floor(max_s/D)+1):
        sugar = math.floor((max_s-i*D)/C)*C+i*D
        max_d = max(max_d,sugar)
    return max_d
den = [max_dens(x)/x for x in water]
index = den.index(max(den))
print(water[index]+max_dens(water[index]),max_dens(water[index]))

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

ans1=1
ans2=0
for i in range(31):
    for j in range(31):
        x=100*(a*i+b*j)
        if x>f:
            continue
        if x==0:
            continue
        
        for k in range(f//c+1):
            for l in range(f//(c+d)+1):
                y=c*k+d*l
                
                if x+y>f or y/(x+y)>e/(100+e):
                    continue
                
                else:
                    if y/(x+y)>=ans2/(ans1+ans2):
                        ans1=x
                        ans2=y
                    else:
                        continue
if x+y!=0:
    print(ans1+ans2,ans2)
else:
    print(a,0)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
sato = set()
miz = set()
for i in range(F//100//A + 1):
	for j in range(F//100//B + 1):
		if i*A + j*B <= F//100:
			miz.add((i*A + j*B)*100)

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

node = 0
note = [100*A, 0]
for i in range(len(miz)):
	if miz[i] == 0:
		continue
	for j in range(len(sato)):
		c = 100*sato[j]/miz[i]
		q = miz[i] + sato[j]
		if c > E:
			pass
		elif q > F:
			pass
		elif c > node:
			note = [miz[i] + sato[j], sato[j]]
			node = c

print(*note)

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

n = 30

noudo = -1
all_s = 0
sato_s = 0

r_flag = False

for i in range(1,(f+99)//100):
    for j in range(30+1):
        if r_flag == True:
            break
        for k in range(30+1):
            if i == j*a+k*b:
                r_flag = True
                break
    if r_flag == False:
        continue
    for j in range(int((i*e)/c)+1):
        e_sato = min(f - i*100-j*c, i*e-j*c)
        d_num = e_sato // d
        tmp_sato = j*c+d_num*d
        tmp_all = tmp_sato + i*100
        tmp_noudo = (100*(tmp_sato)) / tmp_all
        
        if tmp_all > f:
            continue
        if noudo < tmp_noudo:
            noudo = tmp_noudo
            all_s = tmp_all
            sato_s = tmp_sato
            
    r_flag = False


print(all_s,sato_s)

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

maxdense = 0
ans =[0,0]
for i in range(31):
	for j in range(31):
		for k in range(101):
			for l in range(101):
				water = (100*a)*i + (100*b)*j
				sugar = c*k + d*l

				if water == 0:
					break
				if water + sugar > f:
					break
				else:
					if water/100*e >= sugar:
						dense = 100*sugar/(water+sugar)
						if dense >= maxdense:
							maxdense = dense
							ans[0] = water + sugar
							ans[1] = sugar
print(*ans)

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

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

A *= 100
B *= 100

M = -float('inf')
Mwater, Msugar = 0, 0
for a in range(0, F + 1, A) :
    for b in range(0, F - a + 1, B) :
        for c in range(0, F - a - b + 1, C) :
            for d in range(0, F - a - b - c + 1, D) :
                if a + b + c + d == 0 :
                    continue
                if c + d <= (a + b) * E // 100 :
                    if 100 * (c + d) / (a + b + c + d) > M :
                        M = 100 * (c + d) / (a + b + c + d)
                        Mwater = a + b
                        Msugar = c + d
                        
print(Mwater+Msugar, Msugar)

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

    max_d = 0
    max_a, max_b = 100*A, 0
    for i in range(F//(100*A)+1):
        F1 = F - 100*A*i
        for j in range(F1//(100*B)+1):
            F2 = F1 - 100*B*j
            if i+j > 0:
                for k in range(min(F2,(A*i+B*j)*E)//C+1):
                    F3 = F2 - C*k
                    for l in range(min(F3,((A*i+B*j)*E-C*k))//D+1):
                        
                        
                        d = (C*k+D*l) / (A*i+B*j)
                        if d > max_d:
                            max_d = d
                            max_a = C*k+D*l + 100*(A*i+B*j)
                            max_b = C*k+D*l
    return max_a, max_b


if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))

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



max_solvent = 0
max_solute = 0
max_strength = 0.0

for na in range(0, 31):
    for nb in range(0, 31):
        for nc in range(0, 101):
            for nd in range(0, 101):

                solute = nc * C + nd * D
                solvent = 100 * na * A + 100 * nb * B

                
                    
                if solvent == 0:
                    break

                if solute + solvent > F:
                    
                    break

                else:
                    
                    if solvent/100 * E >= solute:
                    
                    
                        strength = 100 * solute / (solute + solvent)
                        
                        if max_strength <= strength:
                            max_strength = strength
                            max_solute = solute
                            max_solvent = solute + solvent

print(max_solvent, max_solute)

Solution (Python):
ope1,ope2,ope3,ope4,concent,capacity = map(int,input().split())
ope1 *= 100
ope2 *= 100
noudo = -1
check = 0
check_capacity = 0
result =""

for i in range(int(capacity / ope1)+1):
    for x in range(int( (capacity -(i*ope1)) /ope2 )+1):
        if i+x == 0:
            continue
        for y in range(int( (capacity -(i*ope1 +x*ope2)) /ope3)+1):
            for z in range( int( (capacity -(i*ope1 +x*ope2 +y*ope3) ) /ope4)+1):
                if y+z ==0:
                    if noudo < 0:
                        noudo = 0
                        result = (str(i * ope1 + x * ope2 + y * ope3 + z * ope4) + " " + str(y * ope3 + z * ope4))
                    continue
                check = (100 *(y*ope3 + z*ope4)) / ( i*ope1 + x*ope2 + y*ope3 + z*ope4)

                if check > noudo and ((i*ope1+x*ope2)/100)*concent>= y*ope3+z*ope4:
                    noudo = check
                    result = (str(i*ope1+x*ope2+y*ope3+z*ope4)+" "+str(y*ope3+z*ope4))
print(result)

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

x = []
y = []

k=0
i = 0
j = 0



while( 100*a*i + 100*b*j <= f ):
  while( 100*a*i + 100*b*j <= f):
    x.append(100*a*i + 100*b*j)
    j +=1
  j = 0
  i +=1
  
i = 0
j = 0
while( c*i + d*j <= f ):
  while( c*i + d*j <= f):
    y.append(c*i + d*j)
    j +=1
  j = 0
  i +=1
      
    
x = list(set(x))
y = list(set(y))

x.remove(0)




noudo = 0
reg_i = 0
reg_j = 0

for i in range(len(x)):
  for j in range(len(y)):
    tmp_noudo = 100 * y[j] / (x[i] + y[j])
    if  tmp_noudo <= 100 * e / (100 + e) and (x[i] + y[j]) <= f:
      if noudo < tmp_noudo:
        noudo = tmp_noudo
        reg_i = i
        reg_j = j
        

print( x[reg_i]+y[reg_j] , y[reg_j] )

Solution (Python):
ope1,ope2,ope3,ope4,concent,capacity = map(int,input().split())
ope1 *= 100
ope2 *= 100
noudo = 0
check = 0
check_capacity = 0
result =str(ope1)+" "+"0"

for i in range(int(capacity / ope1)+1):
    for x in range(int( (capacity -(i*ope1)) /ope2 )+1):
        if i+x == 0:
            continue
        for y in range(int( (capacity -(i*ope1 +x*ope2)) /ope3)+1):
            for z in range( int( (capacity -(i*ope1 +x*ope2 +y*ope3) ) /ope4)+1):
                if y+z ==0:
                    continue
                check = (100 *(y*ope3 + z*ope4)) / ( i*ope1 + x*ope2 + y*ope3 + z*ope4)

                if check > noudo and ((i*ope1+x*ope2)/100)*concent>= y*ope3+z*ope4:
                    noudo = check
                    result = (str(i*ope1+x*ope2+y*ope3+z*ope4)+" "+str(y*ope3+z*ope4))
print(result)

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

Solution (Python):

a, b, c, d, e, f = [ int(v) for v in input().split() ]

water_list =  [ a*100*i + b*100*j for i in range(30) for j in range(30) if  0 < a*100*i + b*100*j < f ]
water_list = sorted(list(set(water_list)))
sugar_water_list = []

def dencity(w,s):
    return (100*s) / (w+s)

for i in water_list:
    limit_sugar = min(int(e * i / 100),f-i)    
    max_sugar = 0
    for j in range(0,limit_sugar//d+1):
        limit_sugar_2 = limit_sugar - j*d
        k = limit_sugar_2 // c
        max_sugar = max(j*d+k*c,max_sugar)
    sugar_water_list.append((dencity(i,max_sugar),i+max_sugar,max_sugar))

print(sorted(sugar_water_list)[-1][1],sorted(sugar_water_list)[-1][2])