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):
def main():
    A, B, C, D, E, F = map(int, input().split())
    A *= 100
    B *= 100
    ans = (0, 0)
    for a in range(F//A+1):
        for b in range((F-A*a)//B+1):
            for c in range((F-A*a-B*b)//C+1):
                for d in range((F-A*a-B*b-C*c)//D+1):
                    if a == b == c == d == 0:
                        continue
                    x = C*c + D*d
                    y = A*a + B*b + x
                    if (100+E) * x <= E * y and ans[0] * x >= ans[1] * y:
                        ans = (y, x)
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()

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

concent = 0
answeight = 100*A
anssugar = 0
for i in range( F//(100*A) + 1 ):
    for j in range( (F - 100*A*i)//B + 1 ):
        water = 100 * (A*i + B*j)
        maxsugar = min( E * (A*i + B*j), F - water )
        if 0 < water:
            for k in range( maxsugar//C + 1 ):
                sugar = C*k + D*((maxsugar - C*k)//D)
                if concent < sugar/(water + sugar):
                    concent = sugar/(water + sugar)
                    answeight = water + sugar
                    anssugar = sugar             

print( answeight, anssugar )

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

concent = 0
answeight = 0
anssugar = 0
for i in range( F//(100*A) + 1 ):
    for j in range( (F - 100*A*i)//B + 1 ):
        water = 100 * (A*i + B*j)
        maxsugar = min( E * (A*i + B*j), F - water )
        if 0 < water:
            for k in range( maxsugar//C + 1 ):
                sugar = C*k + D*((maxsugar - C*k)//D)
                if concent < sugar/(water + sugar):
                    concent = sugar/(water + sugar)
                    answeight = water + sugar
                    anssugar = sugar             

if answeight == 0: print( 100*A, 0 )
else :             print( answeight, anssugar )

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
water = []
for i in range(31):
    for j in range(31):
        if a * i * 100 + b * j * 100 > f:
            break
        water.append(a * i * 100 + b * j * 100)
        
water = sorted(list(set(water)))
sugar = []
for i in range(3001):
    for j in range(3001):
        if c * i + d * j > f:
            break
        sugar.append(c * i + d * j)
        
sugar = sorted(list(set((sugar))))

sugar_ratio = 0
for i in water:
    for j in sugar:
        if i != 0:
            sugar_water = i + j
            if sugar_water <= f:
                if j / i  <= e / 100:
                    if j / sugar_water >= sugar_ratio:
                        sugar_ratio = j / sugar_water
                        ans_sugar_water = sugar_water
                        ans_sugar = j
                        
print(ans_sugar_water, ans_sugar)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
w=set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s=set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)

max=-1
total=0
sugar=0
for x in w:
    for y in s:
        if 0<x+y<=f and y<=x*e//100:
            if max<y/(x+y):
                total=x+y
                sugar=y
                max=y/(x+y)
print(total,sugar)

Solution (Python):

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

Solution (Python):
a,b,c,d,e,f = map(int, input().split())
g = max(a, b)
h = min(a, b)
salt = []
water = []
concentration = 0

for i in range(int(e*f/(c*100)) + 1):
    j = 0
    while e*f/100 >= c*i +d*j:
        salt.append(c*i+d*j)
        j += 1
salt.sort()

for i in range(int(f/(100*g)) + 1):
    j = 0
    while f >= 100*(g*i+h*j):
        water.append(100*(g*i+h*j))
        j += 1
water.sort()
water = water[1:]

for i in range(len(water)):
    addsalt = min(water[i] * e // 100, f - water[i])
    while addsalt not in salt:
        addsalt -=1
    if concentration < addsalt / (water[i] + addsalt):
        concentration = addsalt / (water[i] + addsalt)
        salt1 = addsalt
        water1 = water[i]

try:
    print(salt1+water1, salt1)
except NameError:
    print(water[0], 0)

Solution (Python):
A,B,C,D,E,F=map(int,input().split())
mx_A=F//(100*A)
mx_B=F//(100*B)
mx_C=F//C
mx_D=F//D
Conc=-1
Vol=0
Sal=0
for i in range(mx_A+1):
    for j in range(mx_B+1):
        if 0<100*(A*i+B*j)<=F:
            for k in range(mx_C+1):
                for l in range(mx_D+1):
                    m_Sal=C*k+D*l
                    m_Wat=100*(A*i+B*j)
                    if (m_Sal+m_Wat)<=F and m_Sal<=(E*m_Wat//100):
                        if (m_Sal/(m_Sal+m_Wat))>Conc:
                            Conc=(m_Sal/(m_Sal+m_Wat))
                            Sal=m_Sal
                            Vol=m_Sal+m_Wat
print(Vol,Sal)

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

W = set()
for i in range(0, F + 1, 100 * A):
    for j in range(0, F + 1 - i, 100 * B):
        W.add(i + j)
        
S = set()
for i in range(0, F + 1, C):
    for j in range(0, F + 1 - i, D):
        S.add(i + j)

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

Solution (Python):

"""
Created on Sat Mar  2 01:07:09 2019

@author: yuta
"""

A,B,C,D,E,F = map(int,input().split())
"""
def melt(a,b,c,d,e,f):
    max_sugar = 0
    for i in range(int(0.01*f/a)+1):
        for j in range(int(0.01*f/b)+1):
            for k in range(int((f*e*0.01)/c)+1):
                for l in range(int((f*e*0.01)/d)+1):
                    if i+j+k+l == 0:
                        break
                    else:
                        den = (100*(k*c+l*d))/(100*i*a+100*j*b+k*c+l*d)
                        if den > 100*e/(100+e):
                            den = 0
                        else:
                            if den >= max_sugar and 100*i*a+100*j*b+k*c+l*d <= f:
                                max_sugar = den
                                amount = 100*i*a + 100*j*b + k*c + l*d
                                sugar = 0.01 * den * amount
    print(amount,sugar)

melt(A,B,C,D,E,F)
"""
def melt(a,b,c,d,e,f):
    water = []
    sugar = []
    for i in range(int(0.01*f/a)+1):
        for j in range(int(0.01*f/b)+1):
            water.append(100*(a*i+b*j))
    water = list(set(water))
    
    for k in range(int((f*e*0.01)/c)+1):
        for l in range(int((f*e*0.01)/d)+1):
            sugar.append(c*k+d*l)
    sugar = list(set(sugar))
    
    max_sugar = 0
    for m in range(len(water)):
        for n in range(len(sugar)):
            if water[m]+sugar[n] == 0:
                break
            else:
                den = 100*sugar[n]/(water[m]+sugar[n])
                if den > 100*e/(100+e):
                    den = 0
                else:
                    if den >= max_sugar and water[m]+sugar[n] <= f:
                        max_sugar = den
                        amount = water[m]+sugar[n]
                        sugar_amount = sugar[n]
    print(amount,sugar_amount)
melt(A,B,C,D,E,F)

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

W = set()
for a in range(0, F + 1, 100 * A):
    for b in range(0, F + 1 - a, 100 * B):
        W.add(a + b)
        
S = set()
for c in range(0, F + 1, C):
    for d in range(0, F + 1 - c, D):
        S.add(c + d)
        
rate = -1
for w in W:
    for s in S:
        if 0 < w + s <= F and s / (w + s) <= E / (E + 100):
            if s / (w + s) > rate:
                rate = s / (w + s)
                ans = w + s, s
                
print(ans[0], ans[1])

Solution (Python):
a,b,c,d,e,f = (int(i) for i in input().split())
sa = sab = sabc = sabcd = sc = scd = sugar = dens = 0
water = a*100
for i in range(31):
  sa = a*i*100
  if sa > f:
    break
  for j in range(16):
    sab = b*j*100 + sa
    if sab > f or sab == 0:
      break
    for k in range(1501):
      sc = c*k
      sabc = sc + sab
      if sabc > f or sc > e * sab / 100:
        break
      for l in range(1501):
        scd = sc + d*l
        sabcd = d*l + sabc
        if sabcd > f or scd > e * sab / 100:
          break
        if dens < scd / sabcd:
          dens = scd / sabcd
          water = sabcd
          sugar = scd
print(str(water) + ' ' + str(sugar))

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

Ws = set()
for a in range(0,F+1,100*A):
    for b in range(0,F+1-a,100*B):
        Ws.add(a+b)

Ss = set()
for c in range(0,F+1,C):
    for d in range(0,F+1-c,D):
        Ss.add(c+d)

ans = set()
for w in Ws:
    for s in Ss:
        if 0<w+s<=F and s<=(w//100)*E:
            ans.add((s/(w+s),w,s))
ans = sorted(ans,reverse=True)
print(ans[0][1]+ans[0][2],ans[0][2])

Solution (Python):
def c_sugar_water(A, B, C, D, E, F):
    x = set()  
    y = set()  
    for a in range(0, F + 1, 100 * A):
        for b in range(0, F - a + 1, 100 * B):
            x.add(a + b)
    for c in range(0, F + 1, C):
        for d in range(0, F - c + 1, D):
            y.add(c + d)

    concentration = -1.0  
    tmp = [0, 0]
    for water in x:
        for sugar in y:
            
            if 0 < water + sugar <= F and E * (water // 100) >= sugar:
                if concentration < sugar / (water + sugar):
                    tmp = (water + sugar, sugar)
                    concentration = sugar / (water + sugar)
    ans = '{} {}'.format(*tmp)
    return ans

A, B, C, D, E, F = [int(i) for i in input().split()]
print(c_sugar_water(A, B, C, D, E, F))

Solution (Python):
def c_sugar_water(A, B, C, D, E, F):
    x = set()  
    y = set()  
    for i in range(F // 100 + 1):
        for j in range(F // 100 + 1):
            tmp = 100 * A * i + 100 * B * j
            if tmp <= F:
                x.add(tmp)
            else:
                break  
    for i in range(F):
        for j in range(F):
            tmp = C * i + D * j
            if tmp <= F:
                y.add(tmp)
            else:
                break

    concentration = 0  
    tmp = [0, 0]
    for water in x:
        for sugar in y:
            if water == 0 and sugar == 0:
                continue  
            elif E * (water // 100) < sugar:
                continue  
            elif water + sugar > F:
                continue  
            else:
                if (100 * sugar) / (water + sugar) >= concentration:
                    concentration = (100 * sugar) / (water + sugar)
                    tmp = [water + sugar, sugar]
    ans = '{} {}'.format(tmp[0], tmp[1])
    return ans

A, B, C, D, E, F = [int(i) for i in input().split()]
print(c_sugar_water(A, B, C, D, E, F))

Solution (Python):
a,b,c,d,e,f = map(int, input().split())
water_list = []
for i in range(f+1):
    for j in range(f+1):
        water = a * 100 * i + b * 100 * j
        if water <= f:
            water_list.append(water)
        else:
            break
            
sugar_list = []
for i in range(f+1):
    for j in range(f+1):
        sugar = c * i + d * j
        if sugar <= f:
            sugar_list.append(sugar)
        else:
            break
            
ans = []
for i in list(set(water_list)):
    for j in list(set(sugar_list)):
        if i != 0:
            if float(j) / i  <= e / 100 and (i + j) <= f:
                ans.append((i+j, j))
                
ans_sorted = sorted(ans, key=lambda x: (x[1] / (x[0])))[-1]
print(ans_sorted[0],ans_sorted[1])

Solution (Python):



















from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

li = list(map(int,input().split()))
A, B, C, D, E, F = li[0], li[1], li[2], li[3], li[4], li[5]

A, B = A*100, B*100

N = F//A

waters = set()
sugers = set()

for i in range(N+1):
    j = 0
    while True:
        water = A*i + B*j
        if  water <= F:
            waters.add(water)
        else:
            break
        j += 1

M = F//C

for i in range(M+1):
    j = 0
    while True:
        suger = C*i + D*j
        if suger <= F:
            sugers.add(suger)
        else:
            break
        j += 1

ans = 0
ans_water = 0
ans_suger = 0
for water in waters:
    for suger in sugers:
        if water == 0 or E/(100+E) < suger/(water+suger) or suger+water > F:
            
            continue
        tmp_p = (100*suger)/(water+suger)
        if tmp_p >= ans:
            ans = tmp_p
            ans_water = water
            ans_suger = suger

print("{} {}".format(ans_water+ans_suger, ans_suger))

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
w1,w2,s1,s2,c,lim=IL()
l=[]
for i in range(31):
    for j in range(31):
        w=w1*i*100+w2*j*100
        if w<lim:
            l.append(w)
ans_c=0
ans=[100*w1,0]
for w in l:
    maxs=min(c*w//100,lim-w)
    maxs1=maxs//s1+1
    maxs2=maxs//s2+1
    for i in range(maxs1+1):
        for j in range(maxs2+1):
            s=s1*i+s2*j
            if s+w!=0:
                if s+w<=lim and s<=maxs and ans_c<100*s/(s+w):
                    ans_c=100*s/(s+w)
                    ans=[s+w,s]
print(ans[0],ans[1])

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

for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                water = (100*A)*a + (100*B)*b
                sugar = C*c + D*d

                if (water + sugar) <= F and water > 0:
                    if sugar <= int(water*E/100):
                        density = 100*sugar/(water + sugar)
                        memo[density] = [water + sugar, sugar]

max_density = max(memo)
print(memo[max_density][0], memo[max_density][1])

Solution (Python):
import sys
input = sys.stdin.readline
a,b,c,d,e,f = map(int, input().split())
rec = 0
ans1 = 100*a
ans2 = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                w = 100*a*i + 100*b*j
                s = c*k + d*l
                if w == 0:
                    break
                if s > e*(a*i+b*j):
                    break
                if w + s > f:
                    break
                if s / (w + s) > rec:
                    rec = s / (w + s)
                    ans1 = w + s
                    ans2 = s
print(str(ans1) + ' ' + str(ans2))

Solution (Python):
a, b, c, d, e, f = map(int,input().split())
bs, bw = 0, 1
cansugar, canwater = [False]*(f+1), [False]*(31)
for ta in range(0,(30//a)+1):
    for tb in range(0,(30//b)+1):
        if a*ta + b*tb <= 30:
            canwater[a*ta+b*tb] = True
for tc in range(0,(3000//c)+1):
    for td in range(0,(3000//d)+1):
        if c*tc + d*td <= f:
            cansugar[c*tc+d*td] = True
for ab in range(1,31):
    for cd in range(0,f+1):
        if canwater[ab] and cansugar[cd]:
            w = 100*ab
            s = cd
            if w+s <= f and s/(w+s) >= bs/(bw+bs) and s <= ab*e:
                bw = w
                bs = s
print(bw+bs, bs)

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

a = set()
for i in range(0, F+1, 100*A):
  for j in range(0, F+1-i, 100*B):
    a.add(i+j)
b = set()
for i in range(0, F+1, C):
  for j in range(0, F+1-i, D):
    b.add(i+j)
tmp = -1
for aa in a:
  for bb in b:
    if(0 < aa+bb <= F and bb <= aa*E//100):
      if(tmp < bb/(aa+bb)):
        ans = aa+bb, bb
        tmp = bb/(aa+bb)
print(ans[0], ans[1])

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








a_d = 100*gcd(A,B); b_d = gcd(C,D)
ans_a = 100*A; ans_b = 0
candidate = []

for a in range(a_d,F+1,a_d):
    b_sup = F - a
    for b in range(b_d,b_sup+1,b_d):
        if not(100*b <= a*E):
            continue
        candidate.append([a,b])

for a, b in candidate:
    cnt = 0
    nA = (100*A) // a_d; nB = (100*B) // a_d; na = a // a_d
    
    
    for i in range(-(-na // nA)+1):
        
        if (na-nA*i) % nB == 0:
            cnt += 1
            break
    nC = C // b_d; nD = D // b_d; nb = b // b_d
    
    
    for k in range(-(-nb//nC)+1):
        
        if (nb-nC*k) % nD == 0:
            cnt += 1
            break
    if cnt == 2 and (a+b)*ans_b <= (ans_a+ans_b)*b:
        ans_a = a; ans_b = b
print(ans_a+ans_b,ans_b)

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








a_d = 100*gcd(A,B); b_d = gcd(C,D)
ans_a = 100*A; ans_b = 0
candidate = []

for a in range(a_d,F+1,a_d):
    b_sup = F - a
    for b in range(b_d,b_sup+1,b_d):
        if not(100*b <= a*E and a % a_d == 0 and b % b_d == 0):
            continue
        candidate.append([a,b])

for a, b in candidate:
    cnt = 0
    nA = (100*A) // a_d; nB = (100*B) // a_d; na = a // a_d
    
    
    for i in range(-(-na // nA)+1):
        
        if (na-nA*i) % nB == 0:
            cnt += 1
            break
    nC = C // b_d; nD = D // b_d; nb = b // b_d
    
    
    for k in range(-(-nb//nC)+1):
        
        if (nb-nC*k) % nD == 0:
            cnt += 1
            break
    if cnt == 2 and (a+b)*ans_b <= (ans_a+ans_b)*b:
        ans_a = a; ans_b = b
print(ans_a+ans_b,ans_b)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
X=[]
for ai in range(31):
    water=a*100*ai
    if water>f:
        break
    for bi in range(31):
        water=a*100*ai+b*100*bi
        if water==0 or water>f:
            break
        for ci in range(101):
            sugar=c*ci
            if water+sugar>f:
                break
            for di in range(101):
                sugar=c*ci+d*di
                if water+sugar>f:
                    break
                else:
                    if water>0 and (water/100)*e>=sugar:
                        X.append([water+sugar,sugar])
print(*sorted(X,key=lambda x:(100*x[1]/x[0]))[-1])

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
a100=a*100
b100=b*100
ok=[]
for ai in range(31):
  for bi in range(31):
    for ci in range(101):
      for di in range(101):
        ab= ai*a100+bi*b100
        cd= ci*c+di*d
        if ab + cd >f:
          break
        else:
          if (ab/100)*e>=cd:
            ok.append([ab+cd,cd])

print(*sorted(ok, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
a100=a*100
b100=b*100
ok=[]
for ai in range(31):
  for bi in range(31):
    for ci in range(101):
      for di in range(101):
        ab= ai*a100+bi*b100
        cd= ci*c+di*d
        if ab + cd >f:
          break
        else:
          if (ab/100)*e>=cd:
            ok.append([ab+cd,cd])
print(*sorted(ok, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

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

ans_water, ans_sugar = 100 * a, 0
for i in range(f // (100 * a) + 1):
  water = 100 * a * i
  if water > f:
    break
  for j in range(((f - water) // (100 * b)) + 1):
    water = 100 * a * i + 100 * b * j
    if water == 0 or water > f:
      break
    for k in range(((f - water) // c) + 1):
      sugar = c * k
      if water + sugar > f or sugar > e * water // 100:
        break
      for l in range(((f - water - sugar) // d) + 1):
        sugar = c * k + d * l
        if water + sugar > f or sugar > e * water // 100:
          break
        if sugar / (water + sugar + 1) > ans_sugar / (ans_water + ans_sugar):
          ans_water, ans_sugar = water, sugar

print(ans_water + ans_sugar, ans_sugar)

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

syokuen=[0]

if c == 1 or d == 1:
  for i in range(1500+1):
    syokuen.append(i)
else:
  for i in range(1500//a+1):
    for j in range(1500//b+1):
      if c*i+d*j not in syokuen and c*i+d*j <=1500 :
        syokuen.append(c*i+d*j) 

mizu=[0]
for i in range(30):
  for j in range(30):
      if a*i*100 + b*j*100 not in mizu and a*i*100 + b*j*100<=f:
        mizu.append(a*i*100 + b*j*100)
        
noudo_max = 0.0
for i in range(len(syokuen)):
  for j in range(len(mizu)):
    if mizu[j]+syokuen[i] != 0:
      noudo = syokuen[i]/(mizu[j]+syokuen[i])
      if mizu[j]+syokuen[i] <= f and noudo <= e/(100+e) and noudo >= noudo_max:
        noudo_max = noudo
        ans_syokuen = syokuen[i]
        ans_mizu = mizu[j]

print(ans_syokuen+ans_mizu,ans_syokuen)

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

from itertools import product
w=[]
for i,j in product(range(F//(100*A)+1),range(F//(100*B)+1)):
    if 0<100*A*i+100*B*j<=F:
        w.append(100*A*i+100*B*j)
s=[]
for i,j in product(range(E*F//(100*C)+1),range(E*F//(100*C)+1)):
    if C*i+D*j<=E*(F//100):
        s.append(C*i+D*j)

w.sort()
s.sort()
ans=[]
for a in w:
    for b in s:
        if (a//100)*E>=b and a+b<=F:
            ans.append([a+b,b])
        else:
            break
ans.sort(key=lambda x:x[1]/(x[0]+x[1]),reverse=True)
print(ans[0][0],ans[0][1])

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

from itertools import product
w=[]
for i,j in product(range(F//(100*A)+1),range(F//(100*B)+1)):
    if 0<100*A*i+100*B*j<=F:
        w.append(100*A*i+100*B*j)
s=[]
for i,j in product(range(E*F//(100*C)+1),range(E*F//(100*C)+1)):
    if C*i+D*j<=E*(F//100):
        s.append(C*i+D*j)

w.sort()
s.sort()
ans=[]
for a in w:
    for b in s:
        if (a//100)*E>=b and a+b<=F:
            ans.append([a+b,b])
        else:
            break
ans.sort(key=lambda x:x[1]/(x[0]+x[1]),reverse=True)
print(ans[0][0],ans[0][1])

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def concentrate(water, sugar):
    if water+sugar == 0:
        return 0
    else:
        return sugar/(water+sugar)


A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water_list = set()
sugar_list = set()

max_cont = E/(E+100)

max_water = F//B+1
for i in range(max_water):
    remain = F - B*i
    if remain < 0:
        break
    else:
        j = remain//A
        for k in range(j+1):
            
            water_list.add(A*k+B*i)

max_sugar = F//D+1
for i in range(max_sugar):
    tmp = D*i
    remain = F - tmp
    if remain < 0:
        break
    else:
        j = remain//C
        for k in range(j+1):
            
            sugar_list.add(D*i+C*k)



water_list = sorted(list(water_list))
sugar_list = sorted(list(sugar_list))

max_tmp = 0
ans = [0, 0]
for water in water_list:
    for sugar in sugar_list:
        if water+sugar > F:
            break
        else:
            conc = concentrate(water, sugar)
            if conc > max_cont:
                break
            else:
                if max_tmp <= conc:
                    max_tmp = conc
                    ans = [water, sugar]
print(sum(ans), ans[1])

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def concentrate(water, sugar):
    if water+sugar == 0:
        return 0
    else:
        return sugar/(water+sugar)


A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water_list = []
sugar_list = []

max_cont = E/(E+100)

max_water = F//B+1
for i in range(max_water):
    remain = F - B*i
    if remain < 0:
        break
    else:
        j = remain//A
        for k in range(j+1):
            water_list.append(A*k+B*i)

max_sugar = F//D+1
for i in range(max_sugar):
    tmp = D*i
    remain = F - tmp
    if remain < 0:
        break
    else:
        j = remain//C
        for k in range(j+1):
            sugar_list.append(D*i+C*k)

water_list = sorted(set(water_list))
sugar_list = sorted(set(sugar_list))

max_tmp = 0
ans = [0, 0]
for water in water_list:
    for sugar in sugar_list:
        if water+sugar > F:
            break
        else:
            conc = concentrate(water, sugar)
            if conc > max_cont:
                break
            else:
                if max_tmp <= conc:
                    max_tmp = conc
                    ans = [water, sugar]
print(sum(ans), ans[1])

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

W = set([a+b for a in range(0,F+1,100*A) for b in range(0,F+1-a,100*B)])
S = set([c+d for c in range(0,F+1,C) for d in range(0,F+1-c,D)])

ans_con = -1
max_con = E/(100+E)

for w in W:
    for s in S:
        if 0 < s+w <= F and s/(s+w) <= max_con:
            if ans_con < s/(s+w):
                ans_con = s/(s+w)
                ans_sw = s+w
                ans_s = s

print(ans_sw,ans_s)

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

ans_con = -1
max_con = E/(100+E)*100

a = 0
while F >= 100*A*a:
    b = 0
    while F-100*A*a >= 100*B*b:
        water = 100*(A*a+B*b)
        c = 0
        while F-water >= C*c:
            sugar = C*c+D*max(min(((F-water-C*c)//D),(water*E/100-C*c)//D),0)
            mass = water + sugar
            if 0 < mass <= F:
                con = sugar/mass*100
                if ans_con < con <= max_con:
                    ans_con = con
                    ans_mass = mass
                    ans_sugar = sugar
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

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

ans_con = -1
max_con = E/(100+E)*100

a = 0
while F >= 100*A*a:
    b = 0
    while F-100*A*a >= 100*B*b:
        water = 100*(A*a+B*b)
        c = 0
        while F-water >= C*c:
            d = 0
            while F-water-C*c >= D*d:
                sugar = C*c+D*d
                mass = water + sugar
                if 0 < mass <= F:
                    con = sugar/mass*100
                    if ans_con < con <= max_con:
                        ans_con = con
                        ans_mass = mass
                        ans_sugar = sugar
                d += 1
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

Solution (Python):
A,B,C,D,E,F = map(int,input().split(" "))
LOOP_A = int(F / (100*A)) + 1
LOOP_B = int(F / (100*B)) + 1
LOOP_C = int((F-100) / C) + 1
LOOP_D = int((F-100) / D) + 1
ans = []
temp = []
for i in range(LOOP_A):
    Ac = i
    for j in range(LOOP_B):
        Bc = j
        W = Ac * A * 100 + Bc * B * 100
        if W >= 100 and W <= F:
            for k in range(LOOP_C):
                Cc = k
                if W + (Cc * C) <= F:
                    for l in range(LOOP_D):
                        Dc = l
                        S = Cc * C + Dc * D
                        total = W + S 
                        SW = S / W
                        
                        if F >= total and SW <= E/100:
                            ans.append(str(total) + " " + str(S))
                            temp.append(S / total)
print(ans[temp.index(max(temp))])

Solution (Python):
from itertools import product
a, b, c, d, e, f = map(int, input().split())
A = sorted(list(set(filter(lambda x: 100*x <= f and x,
           [i*a+j*b for i, j in product(range(31), range(16))]))))
B = [min(x*e, f-100*x) for x in A]

C = []
for i in range(len(A)):
    m = 0
    for k in range(29):
        if k*d <= B[i]:
            m = max(m, k*d+(B[i]-k*d)//c*c)
    C.append(m)

Table = [100*a, 0]
for x, y in zip(A, C):
    if y/(100*x+y) > Table[1]/Table[0]:
        Table = [100*x+y, y]
print(Table[0], Table[1])

Solution (Python):
def solve(A, B, C, D, E, F):
    sugers = set()
    for i in range(0, F // C + 1):
        for j in range(0, F // D + 1):
            s = (C * i + D * j)
            if s + 100 * s / E <= F:
                sugers.add(C * i + D * j)
            else:
                break
    sugers = sorted(list(sugers))

    waters = set()
    for i in range(0, F // A + 1):
        for j in range(0, F // B + 1):
            if (A * i + B * j) * 100 <= F:
                waters.add(A * i + B * j)
            else:
                break
    waters = sorted(list(waters))

    dense, w_all, w_suger = 0, A * 100, 0
    for s in sugers:
        for w in waters:
            if s + 100 * w <= F and s <= w * E and w + s > 0:
                densei = 100 * s / (100 * w + s)
                if dense < densei:
                    dense = densei
                    w_all = s + 100 * w
                    w_suger = s
                    break
    return " ".join([str(w_all), str(w_suger)])


if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split(" "))
    print(solve(A, B, C, D, E, F))

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

ma = 0
for aa in range(0, f+1, a * 100):
    for bb in range(0, f - aa + 1, b * 100):
        water = aa + bb
        if water == 0:
            continue
        smax = min(water // 100 * e, f - water)
        for cc in range(0, smax + 1, c):
            dd = (smax - cc) // d * d
            sugar = cc + dd
            ratio = 100 * sugar / float(water + sugar)
            if ratio >= ma:
                ma = ratio
                ans = [water + sugar, sugar]

print(*ans)