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())
waterset = set()
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        water = (A*i + B *j)*100
        if water < F:
            waterset.add(water)
waterset.remove(0)
sugarset = set()
for i in range(F//C + 1):
    for j in range(F//D + 1):
        sugar = C*i + D*j
        if sugar < F:
            sugarset.add(sugar)
best_conc = -1
best_a = -1
best_b = -1
for a in waterset:
    for b in sugarset:
        if a+b >F:
            continue
        if b > E*a/100:
            continue
        conc = 100*b/(a+b)
        if conc > best_conc:
            best_conc = conc
            best_a = a
            best_b = b
print(best_a+best_b,best_b)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
waterset = set()
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        water = (A*i + B *j)*100
        if water < F:
            waterset.add(water)
waterset.remove(0)
sugarset = set()
for i in range(F//C + 1):
    for j in range(F//D + 1):
        sugar = C*i + D*j
        if sugar < F:
            sugarset.add(sugar)
best_conc = -1
best_a = -1
best_b = -1
for a in waterset:
    for b in sugarset:
        if a+b >F:
            continue
        if b > E*a//100:
            continue
        conc = 100*b/(a+b)
        if conc > best_conc:
            best_conc = conc
            best_a = a
            best_b = b
print(best_a+best_b,best_b)

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

ans_t=0
ans_s=0
for a in range(0,F+1,A):
    for b in range(0,F-a+1,B):
        w=a+b
        if w==0: continue
        for c in range(0,F-w+1,C):
            for d in range(0,F-w-c+1,D):
                s=c+d
                t=w+s
                if w*E<s*100: break
                if ans_s*t<=s*ans_t:
                    ans_t=t
                    ans_s=s

print(ans_t,ans_s)

Solution (Python):

import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline

mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="number"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True

 

 

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

for a in range(0,F+1,A):
    for b in range(0,F+1,B):
        mizu.append(a+b)
for a in range(0,F+1,C):
    for b in range(0,F+1,D):
        satou.append(a+b)

mizu.sort()
satou.sort()

ans=None

for a in satou:
    for b in mizu:
        s=a+b
        if(s==0):continue
        if(s>F):break
        if(a*100>E*b):continue
        if(ans==None):ans=[a,s]
        if(a*ans[1]>ans[0]*s):
            ans=[a,s]

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

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




dpW=[False]*(F+1)
dpW[0]=True
for w in (A*100,B*100):
  for j in range(len(dpW)):
    if dpW[j] and j+w<len(dpW):
      dpW[j+w]=True
      
water=[]
for i in range(len(dpW)):
  if dpW[i] and i!=0:
    water.append(i)

maxsugar=int(F*(E/(E+100)))+1
dpS=[False]*(maxsugar+1)
dpS[0]=True
for s in (C,D):
  for j in range(len(dpS)):
    if dpS[j] and j+s<len(dpS):
      dpS[j+s]=True
sugar=[]
for i in range(len(dpS)):
  if dpS[i]:
    sugar.append(i)
    
ans=[0,0]
maxrate=0
for w in water:
  maxS=int(w*(E/100))
  if w+maxS>F:
    maxS=F-w
  
  ok=0
  ng=len(sugar)
  while abs(ok-ng)>1:
    mid=abs(ok+ng)//2
    if sugar[mid]<=maxS:
      ok=mid
    else:
      ng=mid
  if sugar[ok]/w>=maxrate:
    maxrate=sugar[ok]/w
    ans=[w+sugar[ok],sugar[ok]]
print(*ans)

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range((t - C * i) // D + 1):
        s.add(C * i + D * j)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

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

w = set()
for i in range(F // (100 * A) + 1):
    t = F - 100 * A * i
    for j in range(t // (100 * B) + 1):
        a = (A * i + B * j) * 100
        w.add(a)
w.remove(0)

s = set()
t = E * F // 100
for i in range(t // C + 1):
    u = t - C * i
    for j in range(u // D + 1):
        b = C * i + D * j
        s.add(b)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

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

w = set()
for i in range(F // (100 * A) + 1):
    t = F - 100 * i
    for j in range(t // (100 * B) + 1):
        a = (A * i + B * j) * 100
        w.add(a)
w.remove(0)

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < t:
            s.add(b)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

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

Solution (Python):
a,b,c,d,e,f = map(int,input().split())
w = []
for i in range(f//100//a+1):
    for j in range(f//100//b+1):
        if (i*a + j*b)*100 <= f:
            w.append(i*100*a + j*100*b)
w = set(w)
w.remove(0)
s = []
for i in range(e*f//100//c+1):
    for j in range(e*f//100//d+1):
        if i*c + j*d <= e*f//100:
            s.append(i*c + j*d)
s = sorted(set(s))

ans = []
for i in w:
    for j in s:
        if i != 0 and j <= e* i//100 and i+j <= f:
            ans.append([j/(i+j), j+i, j])
ans.sort()
print(ans[-1][1], ans[-1][2])

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < t:
            s.add(b)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    t = min(F - a, E * a // 100)
    for i in range(t // C + 1):
        for j in range(t // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)

Solution (Python):
from bisect import bisect_right

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < t:
            s.add(b)
s = list(s)
s.sort()

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    i = bisect_right(s, min(E * a // 100, F - a))
    if i == 0:
        continue
    b = s[i - 1]
    concentration = 100 * b / (a + b)
    if concentration > best_concentration:
        best_concentration = concentration
        best_a = a
        best_b = b
print(best_a + best_b, best_b)

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < t:
            s.add(b)
s = list(s)
s.sort()

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in s:
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < F:
            s.add(b)
s = list(s)
s.sort()

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in s:
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

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

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in s:
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

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

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in s:
        if a + b > F:
            continue
        if b > E * a // 100:
            continue
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for i in range((F - a) // C + 1):
        for j in range((F - a) // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for i in range((F - a) // C + 1):
        for j in range((F - a) // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            if a + b == 0:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    t = min(F - a, E * a // 100)
    for i in range(t // C + 1):
        for j in range(t // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            if a + b == 0:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water = set()
sugar = set()
answer = 0.0
answer1 = [0, 0]
w, s = 0, 0
i = 0
while True:
    j = 0
    if 100 * A * i + 100 * B * j > F:
        break
    while True:
        w = 100 * A * i + 100 * B * j
        if w > F:
            break
        water.add(w)
        j += 1
    i += 1

i = 0
while True:
    j = 0
    if C * i + D * j > F:
        break
    while True:
        s = C * i + D * j
        if s > F:
            break
        sugar.add(s)
        j += 1
    i += 1




for i in water:
    for j in sugar:
        
        if i != 0:
            if E / 100 >= j / i and F >= i + j:
                if answer <= j / i:
                    answer = j / i
                    answer1 = i + j, j
                    

print(*answer1)

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

water = set()
sugar = set()
res = {}
noudo = []

counter = max([int(F / A), int(F / B)])
A_counter = int(F / (A * 100))
B_counter = int(F / (B * 100))
for i in range(A_counter + 1):
    for j in range(B_counter + 1):
        tmp = A * i * 100 + B * 100 * j
        if tmp <= F:
            water.add(tmp)

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

water.remove(0)


for w in water:
    for s in sugar:
        if w + s <= F and s <= E * (w / 100):
            n = s / (w + s)
            noudo.append(n)
            res[n] = {"satoumizu": w + s, "sugar": s}
ans = res[max(noudo)]

print(str(ans["satoumizu"]) + " " + str(ans["sugar"]))

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

W = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))
S = [max([c*C + d*D for c in range(int((E*w / 100) / C) + 1) for d in range(int((E*w / 100) / D) + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]
print(100*A if W[I] == 0 else W[I] + S[I], S[I])

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

ans = 0
sub = [0,0]

for i in range(31):
    for g in range(31):
        water = 100*a*i+100*b*g
        if water<=f and water!=0:
            r1 = f-water
            r2 = e*water//100
            _min = min(r1,r2)
            repeat_c = _min//c
            max_sugar = 0
            for m in range(repeat_c+1):
                n=(_min-c*m)//d
                if n>=0:
                    max_sugar = max(max_sugar,c*m+d*n)
            if ans<=max_sugar/(max_sugar+water):
                ans = max_sugar/(max_sugar+water)
                sub[0]=max_sugar+water
                sub[1]=max_sugar
print(*sub)

Solution (Python):
A, B, C, D, E, F = list(map(int, input().split()))
consentration_max = 0
suger_water_max = 0
suger_max = 0
for A_cnt in range(0, 31):
    for B_cnt in range(0, 31):
        water = A_cnt * 100 * A + B_cnt * 100 * B
        if water > F or water <= 0:
            continue
        max_solt = int(E*water/100)
        for C_cnt in range(0, int(max_solt/C)+1):
            for D_cnt in range(0, max(int((max_solt - C_cnt*C)/D) + 1, 1)):
                suger = C_cnt * C + D_cnt * D
                consentration = suger/(water+suger)
                if consentration_max <= consentration and (water+suger) <= F:
                    consentration_max = consentration
                    suger_water_max = water+suger
                    suger_max = suger
print("{} {}".format(suger_water_max, suger_max))

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

X = set([])
Y = set([])

ans = (-1, 0, 0)
for w1 in range(0, F+1, 100*A):
    for w2 in range(0, F-w1+1, 100*B):
      w = w1+w2  
      for s1 in range(0, min(F-w+1, w//100*E+1), C):
        for s2 in range(0, min(F-w-s1+1, w//100*E-s1+1), D):
          s = s1+s2  
          a = w+s
          ans = max(ans, (s/a if a!=0 else -1, a, s))
print(ans[1], ans[2])

Solution (Python):
a,b,c,d,e,f = map(int,input().split())
A =a* 100
B =b* 100
l = []
for i in range(f//A+1):
    for j in range(f//B+1):
        if i*A+j*B <=f:
            W = i*A+j*B
            s = (W//100)*e
            
            r = f - W
            for I in range(s//c+1):
                for J in range(s//d+1):
                    if I*c + J*d<=s and I*c + J*d+W <= f and W>0:
                        S =I*c + J*d
                        l.append([100*S/(W+S),W+S,S])
l.sort()

l = l[::-1]

print(l[0][1],l[0][2])

Solution (Python):
from itertools import product
A, B, C, D, E, F = map(int, input().split())
ans = (-1, 0, 0)
for w1 in range(0,F+1,100*A):
    for w2 in range(0,F-w1+1,100*B):
        w = w1+w2
        for s1 in range(0,min(F-w+1,w//100*E+1),C):
            for s2 in range(0,min(F-w-s1+1,w//100*E-s1+1),D):
                s = s1+s2
                a = w+s
                ans = max(ans, (s/a if a!=0 else -1, a, s))
print(ans[1], ans[2])

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
W = []
S = []
for a in range(F//100+1):
    for b in range(F//100+1):
        w = A*a+B*b
        if 1 < 100*w < F:
            W.append(w)
            slist = []
            for c in range((F-100*w)//C+1):
                for d in range((F-100*w)//D+1):
                    if C*c+D*d <= F-100*w:
                        slist.append(C*c+D*d)
            S.append(slist)
maxs = [100*A,0]
rel = 0
for w in range(len(W)):
    for s in range(len(S[w])-1,-1,-1):
        if E*W[w] >= S[w][s]:
            if rel < 100*S[w][s]/(W[w]+S[w][s]):
                maxs = [100*W[w]+S[w][s],S[w][s]]
                rel = 100*S[w][s]/(W[w]+S[w][s])
print(*maxs)

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














X = []
Y = []
Den = []
for i in range(31):
    for j in range(31):
        x = 100*A*i + 100*B*j
        for l in range(101):
            for m in range(101):
                y = C*l + D*m
                if 0 < x + y <= F and (y/(x+y)) <= (E/(100+E)):
                    X.append(x)
                    Y.append(y)
                    density = y/(x+y)
                    Den.append(density)
max_d = 0
max_i = 0
for i in range(len(Den)):
    if Den[i] > max_d:
        max_d = Den[i]
        max_i = i

print(X[max_i]+Y[max_i], Y[max_i])

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
a=100*a
b=100*b
dp1=[0]*(f+1)
dp2=[0]*(f+1)
for i in range(f+1):
    if i%a==0:
        if i+a<=f:
            dp1[i+a]=1
for i in range(f+1):
    if i==0 or dp1[i]==1:
        if i+b<=f:
            dp1[i+b]=1
for i in range(f+1):
    if i%c==0:
        if i+c<=f:
            dp2[i+c]=1
for i in range(f+1):
    if i==0 or dp2[i]==1:
        if i+d<=f:
            dp2[i+d]=1


ans=[-1,-1,-1]
for i in range(f+1):
    if dp1[i]==1:
        x=min(f-i,(i//100)*e)
        k=-1
        for j in range(x,-1,-1):
            if dp2[j]==1 or j==0:
                k=j
                if ans[0]<100*k/(i+k):
                    ans=[100*k/(i+k),i+k,k]
                break
print(str(ans[1])+" "+str(ans[2]))

Solution (Python):

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

density = -1
ans = (0, 0)

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
        suger = c*C + d*D
         
        if water + suger > F or water == 0:
          break

        if (water / 100) * E >= suger:
        
          tmp = (100 * suger)  / (water + suger)

          if tmp > density:
            density = tmp
            ans = (water+suger, suger)

print(*ans)

Solution (Python):

def solve():
    
    A, B, C, D, E, F = map(int, input().split())
    memo = {}
    
    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    w = (100*A)*a + (100*B)*b
                    s = C*c + D*d
                    if w ==0:
                        break
                    if w+s > F:
                        break
                    else:
                        if w/100 * E >= s:
                            density = 100*s/(w+s)
                            memo[a,b,c,d] = density
    
    max_v = max(memo.values())
    
    for k, v in memo.items():
        if v == max_v:
            print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
            break
solve()

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

ans = [0,0]
per = -1

for w in range(1,f+1):
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue
    water = w*100

    for s in range(min(w*E,F-water),-1,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break

    if s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))

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

ans = [0,0]
per = -1

for w in range(1,f+1):
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100

    for s in range(min(w*E,F-water),-1,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break

    if s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))

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

ans = [0,0]
per = -1

for w in range(1,f+1):
    
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    st = 0
    
    for s in range(min(w*E,F-water),-1,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break

    if s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))

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

ans = [0,0]
per = -1

for w in range(1,f+1):
    
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    sugar = min(w*E,F-water)
    if ans[0] == 0:
        ans[0] = water
    st = 0
    
    for s in range(sugar,0,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break
    if st == 1 and s+water <= F and s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))

Solution (Python):

A,B,C,D,E,F = map(int,input().split(' '))
ans = [0,0]
r = 0
for i in range(F//A+1):
    for j in range(F//B+1):
        if (i == 0 and j == 0) or  100*(A*i+B*j) > F:
            break
        for k in range(F//C+1):
            for l in range(F//D+1):
                tmp = 100*A*i+100*B*j+C*k+D*l
                r_tmp = 100*(C*k+D*l)/tmp
                if tmp > F:
                    break
                if r <= r_tmp and 100*(C*k+D*l)/(100*(A*i+B*j)) <=E:
                    r = r_tmp
                    ans = [tmp,C*k+D*l]
print(ans[0],ans[1])

Solution (Python):
A, B, C, D, E, F = tuple(map(int, input().split()))
max_con = 0
res = (100 * A, 0)
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        if i == 0 and j == 0:
            continue
        wat = (A * i + B * j)
        x = 100 * wat
        if F < x:
            continue
        for k in range(wat * E // C + 1):
            for l in range(wat * E // D + 1):
                y = C * k + D * l
                if wat * E < y:
                    continue
                total = x + y
                if F < total:
                    continue
                if max_con < y / total:
                    max_con = y / total
                    res = (total, y)
                    
print(*res)