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())
s = [0,0,0,0]
con1 = 0
for x in range(31):
    for y in range(31):
        for v in range(1501):
            if x == y == 0:
                continue
            else:
                w1 = (f-(100*a*x + 100*b*y + c*v))//d

                w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d)
                w = min(w1,w3)
                con2 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w)
                if con1 <= con2 and w >= 0:
                    con1 = con2
                    s = [x,y,v,w]
                else:
                    continue

ans1 = 100*a*s[0] + 100*b*s[1] + c*s[2] + d*s[3]
ans2 = c*s[2] + d*s[3]
print(ans1,ans2)

Solution (Python):
a,b,c,d,e,f = map(int, input().split())
s = [0,0,0,0]
con1 = 0
for x in range(31):
    for y in range(31):
        for v in range(1501):
            if x == y == 0:
                continue
            else:
                w1 = (f-(100*a*x + 100*b*y + c*v))//d
                w2 = (100*a*x + 100*b*y -c*v)//d
                w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d)
                w = min(w1,w2,w3)
                con2 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w)
                if con1 <= con2 and w >= 0:
                    con1 = con2
                    s = [x,y,v,w]
                else:
                    continue

ans1 = 100*a*s[0] + 100*b*s[1] + c*s[2] + d*s[3]
ans2 = c*s[2] + d*s[3]
print(ans1,ans2)

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

CCT = {}

for a in range(F//(100*A) +1): 
    for b in range((F-a*A*100)//(100*B) +1): 
        water = (a*A+b*B)*100
        max_suger = water*E//100
        for c in range(max_suger//C +1): 
            for d in range((max_suger-c*C)//D +1): 
                suger = c*C+d*D
                total = water + suger
                if total > F or total == 0 or max_suger < suger:
                    continue
                CCT[water,suger] = suger/total

ans = (A*100, 0)
max_cct = 0
for (water,suger),cct in CCT.items():
    if cct > max_cct:
        max_cct = cct
        ans = (water+suger, suger)
print(*ans)

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

CCT = {}
for a in range(F//(100*A)+1):
    for b in range(F//(100*B)+1):
        water = (a*A+b*B)*100
        if water > F:
            continue
        max_suger = water*E//100
        for c in range(max_suger//C+1):
            for d in range((max_suger-c*C)//D+1):
                suger = c*C+d*D
                total = water + suger
                if total > F or total == 0 or max_suger < suger:
                    continue
                CCT[water,suger] = suger/total

ans = (A*100, 0)
max_cct = 0
for (water,suger),cct in CCT.items():
    if cct > max_cct:
        max_cct = cct
        ans = (water+suger, suger)
print(*ans)

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

CCT = {}
for a in range(F//(100*A)+1):
    for b in range(F//(100*B)+1):
        water = (a*A+b*B)*100
        if water > F:
            continue
        max_suger = water*E//100
        for c in range(max_suger//C+1):
            for d in range(max_suger//D+1):
                suger = c*C+d*D
                total = water + suger
                if total > F or total == 0:
                    continue
                if max_suger < suger:
                    continue
                CCT[water,suger] = suger/total

ans = (A*100, 0)
max_cct = 0
for (water,suger),cct in CCT.items():
    if cct > max_cct:
        max_cct = cct
        ans = (water+suger, suger)
print(*ans)

Solution (Python):
import sys
water1,water2,sugar1,sugar2,per_limit,total_limit = map(int,input().split())

max_sugar_per_water = 0
best_total = 0
best_sugar = 0


if per_limit == 0:
    print(100*water1)
    sys.exit()

for time_water1 in range(30):
    for time_water2 in range(30):
        water = water1*time_water1*100 + water2*time_water2*100
        if water > total_limit:
            break
        if water == 0:
            continue

        sugar_limit = (water//100)*per_limit
        time_sugar1 = 0
        while True:
            time_sugar2 = 0
            while True:
                sugar = sugar1*time_sugar1+sugar2*time_sugar2

                
                if total_limit < water+sugar:
                    break
                
                if sugar_limit < sugar:
                    break

                
                sugar_per_water = sugar/water
                if sugar_per_water >= max_sugar_per_water:
                    max_sugar_per_water = sugar_per_water
                    best_sugar = sugar
                    best_total = sugar+water

                
                time_sugar2 += 1

            
            if sugar1*time_sugar1 > sugar_limit or sugar1*time_sugar1 + water > total_limit:
                break
            
            time_sugar1 += 1

        if water > total_limit:
            break
print(best_total,best_sugar)

Solution (Python):
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter



input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  
    fac = [0] * SIZE  
    finv = [0] * SIZE  
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    
    
    
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    
    return X.flatten().tolist()[0]

class TwoDimGrid:
    
    def __init__(self, h, w, wall="
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        
        
        
        
        

def solve():
    a, b, c, d, e, f = getList()
    dp = [[0 for i in range(f+1)] for j in range(f+1)]
    dp[0][0] = 1
    for i in range(f):
        for j in range(f):
            if dp[i][j] == 1:
                if i + a * 100 <= f:
                    dp[i+a*100][j] = 1
                if i + b * 100 <= f:
                    dp[i+b*100][j] = 1
                if i + c <= f:
                    dp[i+c][j+c] = 1
                if i + d <= f:
                    dp[i+d][j+d] = 1

    ans = (a*100, 0)

    for i in range(1, f+1):
        for j in range(f+1):
            if dp[i][j] == 1:
                if e * (i-j) / 100 >= j:
                    if ans[1]/ans[0] < j/i:
                        ans = (i, j)


    print(*ans)





def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

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

x, y = a, 0  
conc_best = 0

for i in range(f // a + 1):
    for j in range(((f - a * i) // b) + 1):
        water = i * a + j * b
        if water == 0:
            continue
        rest = f - water
        sug_max = e * water / 100
        for k in range(rest // c + 1):
            for l in range((rest - c * k) // d + 1):
                sugar = c * k + d * l
                conc = sugar / (sugar + water)

                if sugar <= sug_max and conc> conc_best:
                        conc_best = conc
                        x, y = sugar+water , sugar
print(x, y)

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

wat = 0
wat_list = []
for i in range(f//a+1):
    for j in range(f//b+1):
        wat = a*i+b*j
        if 0 < wat <= f:
            wat_list.append(wat)

sug = 0
conc = 0
sug_max = 0 
conc_best = 0
sug_best = 0 
sug_wat_best = 0

for k in wat_list:
    sug_max = k//100 * e
    for l in range(sug_max // c + 1):
        for m in range(sug_max //d + 1):
            sug = c*l+d*m
            conc = sug/(sug+k)*100
            if 0<= sug <= sug_max and k+sug <= f and conc_best <= conc :
                conc_best = conc
                sug_wat_best = sug + k
                sug_best = sug
print(sug_wat_best, sug_best)

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

a *= 100
b *= 100


wat = 0
wat_list = []
for i in range(f//a+1):
    for j in range(f//b+1):
        wat = a*i+b*j
        if 0 < wat <= f:
            wat_list.append(wat)


sug = 0
sug_max = 0
sug_list = []
conc_list = []
sug_wat_list = []
for k in wat_list:
    sug_max = k//100 * e
    for l in range(sug_max // c + 1):
        for m in range(sug_max //d + 1):
            sug = c*l+d*m
            if 0<= sug <= sug_max and k+sug <= f: 
                sug_list.append(sug)
                conc_list.append(sug/(sug+k)*100)
                sug_wat_list.append(sug+ k)

idx = conc_list.index(max(conc_list))
print(sug_wat_list[idx], sug_list[idx])

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

anum = f // (100*a)
bnum = f // (100*b)

cp = 0
for ca in range(anum+1):
    for cb in range(bnum+1):
        water = (a*ca + b*cb)*100
        if water > f:
            continue
        cnum = e * (a*ca+b*cb) // c
        dnum = e * (a*ca+b*cb) // d
        for cc in range(cnum+1):
            for cd in range(dnum+1):
                sugar = c*cc + d*cd
                
                if water + sugar <= 0 or water + sugar > f or sugar > e * (a*ca+b*cb):
                    continue
                p = 100 * sugar / (water + sugar)
                if p >= cp:
                    cp = p
                    ans = [str(water + sugar), str(sugar)]
print(' '.join(ans))

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, c, d, e, f = LI()

x = f // (100*a)
y = f // (100*b)

max_ = -1
max__ = 1
for i in range(x + 1):
    for j in range(y + 1):
        E = min((a*i + b*j) * e, f - (100*a*i + 100*b*j))
        min_ = inf
        for k in range(E // c + 1):
            for l in range(E // d + 1):
                if c*k + d*l > E:
                    continue
                min_ = min(min_, E - c*k - d*l)
        E -= min_
        if max_ * (a*i + b*j) < E * max__:
            max_ = E
            max__ = a*i + b*j
            ans1 = (a*i + b*j) * 100 + E
            ans2 = E
print(ans1, ans2)

Solution (Python):
import sys

a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100
thr = e / (e + 100) * 100

water = set()
sugar = set()

for i in range(f // a + 1):
    for j in range((f - i * a) // b + 1):
        if i + j >= 1:
            water.add(i * a + j * b)

for i in range(f // c + 1):
    for j in range((f - i * c) // d + 1):
        sugar.add(i * c + j * d)

water = list(water)
sugar = list(sugar)
water.sort()
sugar.sort()

result = []
for w in water:
    for s in sugar:
        dens = s / (w + s) * 100
        if w + s > f or dens > thr:
            continue
        else:
            result.append((dens, w + s, s))

if len(result) == 0:
    print(-1)
    sys.exit()
else:
    result.sort(reverse=True)
    print(result[0][1], result[0][2])

Solution (Python):
import sys
 
A, B, C, D, E, F = map(int, sys.stdin.readline().split())
 
max_a = (F - 1) // (100 * A) + 1
max_b = (F - 1) // (100 * B) + 1
 
max_rate = 0
ans_water = 0
ans_sugar = 0
for a in range(max_a + 1):
    for b in range(max_b + 1):
        water = 100 * A * a + 100 * B * b
        if water >= F:
            break
 
        max_sugar = min(F - water, water // 100 * E)
        
        max_c = (max_sugar - 1) // C + 1
        max_d = (max_sugar - 1) // D + 1
        for c in range(max_c + 1):
            for d in range(max_d + 1):
                sugar = C * c + D * d
                if sugar > max_sugar or sugar + water > F:
                    break
 
                if sugar * (ans_water + ans_sugar) >= ans_sugar * (water + sugar):
                    ans_water = water
                    ans_sugar = sugar
 
print(ans_water + ans_sugar, ans_sugar)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
a = 0
x = 100*A
y = 0
for n in range(30):
    for m in range(30):
        if n*100*A+m*100*B>F:continue
        c = (n*A+m*B)*E
        d = F-100*(n*A+m*B)
        for k in range(min(c,d)+1):
            for l in range(min(c,d)+1):
                if k*C+l*D>(n*A+m*B)*E or n*100*A+m*100*B+k*C+l*D>F:continue
                if x*(k*C+l*D)>y*(n*100*A+m*100*B+k*C+l*D):
                    x = n*100*A+m*100*B+k*C+l*D
                    y = k*C+l*D
                    a = y/x
print(x,y)

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

i = 0
while True:
    j = 0
    if 100*a*i + 100*b*j > f:
        break
    while True:
        if 100*a*i + 100*b*j <= f:
            water.add(100*a*i + 100*b*j)
        else:
            break
        j += 1
    i += 1

i = 0
while True:
    j = 0
    if c*i + d*j > f:
        break
    while True:
        if c*i + d*j <= f:
            sugar.add(c*i + d*j)
        else:
            break
        j += 1
    i += 1


nodo = 0.0
ans = [0, 0]
for w in water:
    for s in sugar:
        if w != 0:
            if e/100 >= s/w and f >= s+w:
                if nodo <= s/w:
                    nodo = s/w
                    ans = s+w, s

print(*ans)

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
con = -1
ans0 = -1
ans1 = -1
 
for a in range(31):
    for b in range(31):
        if a==0 and b==0:
            continue
        
        for c in range(3001):
            for d in range(3001):
                water = 100*A*a+100*B*b
                sugar = C*c+D*d
                
                if water+sugar>F:
                    break
                
                if sugar>(A*a+B*b)*E:
                    break
                
                if 100*sugar/(water+sugar)>con:
                    con = 100*sugar/(water+sugar)
                    ans0 = water+sugar
                    ans1 = sugar
 
print(ans0, ans1)

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

for x in range(F//(100*A)+1):
    for y in range((F-100*A*x)//(100*B)+1):
        if x == y == 0: continue
        sugarMAX = (A*x+B*y)*E
        M = F-100*A*x-100*B*y
        water = 100*A*x+100*B*y
        for z in range(M//C+1):
            for w in range((M-C*z)//D+1):
                sugar = C*z+D*w
                if sugar <= sugarMAX:
                    if ans[1]*(sugar+water) < sugar*ans[0]:
                        ans = [sugar+water, sugar]
                else:
                    break
print(*ans)

Solution (Python):
from bisect import bisect_left, bisect_right

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

ws = set()
for i in range(31):
    for j in range(31):
        v = a*i + b*j
        if 0 < v <= f:
            ws.add(v) 
waters = list(ws)
waters.sort()

ss = set()
for i in range(3001):
    for j in range(3001):
        v = i*c +j*d
        if v <= f:
            ss.add(v)
        else:
            break 

sugars = list(ss)
sugars.sort()

max_sugar, max_water = 0, waters[0]
for w in waters:
    s_max1 = f - w
    s_max2 = (w//100)*e
    s_max = min(s_max1, s_max2)
    ind = bisect_right(sugars, s_max) - 1
    ind = ind if 0 <= ind < len(sugars) else None
    if ind is None:
        continue
    else:
        sugar = sugars[ind] if ind is not None else None
        if sugar*(max_sugar+max_water) > max_sugar*(sugar+w):
            max_sugar = sugar
            max_water = w

print(max_sugar+max_water, max_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,100*B):
        if a+b > F: break
        ws.add(a+b)
ws.remove(0)

ss = set()
for c in range(0,F+1,C):
    for d in range(0,F+1,D):
        if c+d > F: break
        ss.add(c+d)

best_s = -1
best_w = 1
for w in ws:
    for s in ss:
        if w+s > F: continue
        if E*w < s*100: continue
        if best_s * (s+w) < s * (best_s + best_w):
            best_s = s
            best_w = w
print(best_s+best_w, best_s)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, C, D, E, F = LI()

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

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

    
    
    ans = [A, 0]
    for i, j in itertools.product(w, s):
        if 100 * i + j <= F and j <= i * E:
            
            if j * (100 * ans[0] + ans[1]) > ans[1] * (100 * i + j):
                ans[0] = i
                ans[1] = j

    print(ans[0] * 100 + ans[1], ans[1])

if __name__ == '__main__':
    resolve()

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, C, D, E, F = LI()

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

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

    ans = [A, 0]
    c = 0
    for i in w:
        ng = len(s)
        ok = -1
        while abs(ok-ng)>1:
            m = (ng+ok)//2
            if s[m] <= E * i and s[m] + 100 * i <= F:
                ok = m
            else:
                ng = m
        if 0 <= ok < len(s) and 100 * s[ok] / (i + s[ok]) > c:
            ans = [i, s[ok]]
            c = 100 * s[ok] / (i + s[ok])

    print(ans[0] * 100 + ans[1], ans[1])

if __name__ == '__main__':
    resolve()

Solution (Python):
A,B,C,D,E,F = (int(T) for T in input().split())
SugM = 0
WatM = 100*A
for TC in range(0,F+1):
    for TD in range(0,F+1):
        Suger = C*TC+D*TD
        RestS = F-Suger
        if RestS>=0:
            for TA in range(0,(RestS//100)+1):
                for TB in range(0,(RestS//100)+1):
                    if TA==TB==0:
                        continue
                    else:
                        Water = TA*A*100+TB*B*100
                        RestW = RestS-Water
                        if RestW>=0 and Water>=(100*Suger)/E:
                            if SugM/(WatM+SugM)<Suger/(Water+Suger):
                                SugM = Suger
                                WatM = Water
                        else:
                            break
        else:
            break
print('{} {}'.format(WatM+SugM,SugM))

Solution (Python):
A,B,C,D,E,F = (int(T) for T in input().split())
SugM = 0
WatM = 100*A
for TA in range(0,(F//100)+1):
    for TB in range(0,(F//100)+1):
        if TA==TB==0:
            continue
        else:
            Water = TA*100*A+TB*100*B
            RestW = F-Water
            if RestW>=0:
                for TC in range(0,RestW+1):
                    for TD in range(0,RestW+1):
                        Suger = TC*C+TD*D
                        RestS = RestW-Suger
                        if RestS>=0 and Water>=(100*Suger)/E:
                            if Suger/(Suger+Water)>SugM/(SugM+WatM):
                                SugM = Suger
                                WatM = Water
                        else:
                            break
            else:
                break
print('{} {}'.format(WatM+SugM,SugM))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
ans1 = A
ans2 = 0
for i in range(A, F // 100 + 1):
  if any((i - A * j) % B == 0 for j in range(i // A + 1)):
    x = min(E * i, F - i * 100)
    e = max([C * j + (x - C * j) // D * D for j in range(x // C + 1)])
    if e * ans1 > ans2 * i:
      ans1 = i
      ans2 = e
print(ans1 * 100 + ans2, ans2)

Solution (Python):
def main():
    a, b, c, d, e, f = map(int, input().split())
    max_weight = f // 100
    best_water = a
    best_suger = 0
    best_density = 0
    is_ideal = False
    for water in range(a, max_weight + 1):
        max_a = water // a
        max_b = water // b
        is_exist = False

        for add_a in range(max_a):
            water_a = (add_a + 1) * a
            is_exist = water_a + (water - water_a) // b * b == water
            if is_exist:
                break

        if not is_exist:
            for add_b in range(max_b):
                water_b = (add_b + 1) * b
                is_exist = water_b + (water - water_b) // a * a == water
                if is_exist:
                    break

        if is_exist:
            max_suger = e * water
            remaining = min(f - water * 100, max_suger)
            max_c = remaining // c
            max_d = remaining // d

            for add_c in range(max_c):
                sugar_c = (add_c + 1) * c
                sugar = sugar_c + (remaining - sugar_c) // d * d
                density = sugar / (water + sugar)
                if density > best_density:
                    best_density = density
                    best_water = water
                    best_suger = sugar
                    is_ideal = sugar == max_suger
                    if is_ideal:
                        break

            if not is_ideal:
                for add_d in range(max_d):
                    sugar_d = (add_d + 1) * d
                    sugar = sugar_d + (remaining - sugar_d) // c * c
                    density = sugar / (water + sugar)
                    if density > best_density:
                        best_density = density
                        best_water = water
                        best_suger = sugar
                        is_ideal = sugar == max_suger
                        if is_ideal:
                            break
            if is_ideal:
                break

    print(f'{best_water * 100 + best_suger} {best_suger}')


if __name__ == '__main__':
    main()

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 100*min(A, B)
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range((F-(100*A*i)-(100*B*j))//C+1):
            for l in range((F-(100*A*i)-(100*B*j)-(C*k))//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if water == 0:
                    break
                if sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 2 10 20 15 200"""
        output = """110 10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 1 2 100 1000"""
        output = """200 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """17 19 22 26 55 2802"""
        output = """2634 934"""
        self.assertIO(input, output)


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    N = 0
    W = 100*A
    S = 0
    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    w = A*i+B*j
                    s = C*k+D*l
                    if w == 0 or 100*w+s > F or s > w*E:
                        break
                    n = 100*s / (100*w+s)
                    if n > N:
                        N = n
                        W = 100*w+s
                        S = s
    print(f"{W} {S}")


if __name__ == "__main__":
    
    resolve()

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

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

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

	
	

	max_c = -1
	max_w = 0
	max_s = 0

	for w in water:
		for s in sugar:
			if w + s <= F:
				if s / w <= E / 100:
					if s * 100 / (w + s) > max_c:
						max_c = s * 100 / (w + s)
						max_w = w
						max_s = s

	print(max_w + max_s, max_s)

 
if __name__ == "__main__":
  	main()

Solution (Python):








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


suger = []
for i in range(0, f+1):
    for j in range(0, f+1):
        tmp = c*i + d*j
        if (tmp <= f):
            suger.append(tmp)
suger = list(set(suger))


watter = []
for i in range(0, f+1, 100):
    for j in range(0, f+1, 100):
        tmp = (a*i + b*j)
        if (tmp <= f):
            watter.append(tmp)

watter = list(set(watter))


max_conset = -1.0
ans_watter = 0
ans_sugger = 0




for i in range(len(watter)):
    for j in range(len(suger)):

        if (0 < suger[j] + watter[i] <= f):
            if (watter[i] // 100 * e >= suger[j]):
                consent = 100 * suger[j] / (watter[i] + suger[j])
                if (max_conset < consent):
                    ans_watter = watter[i] + suger[j]
                    ans_sugger = suger[j]
                    max_conset = consent

print(ans_watter, ans_sugger)

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

x = []
for i in range(0,F+1,A*100):
    for j in range(0,F+1,B*100):
        water = i + j
        if water > F:
            break
        x.append(water)

y = []
for i in range(0,F+1,C):
    for j in range(0,F+1,D):
        sugar = i + j
        if sugar > F:
            break
        y.append(sugar)

x = sorted(set(x))[1::]
y = sorted(set(y))

n = 0
WS = S = 0
for w in x:
    for s in y:
        if w + s > F:
            break
        if w * E//100 >= s:
            m = 100 * s / (w + s)
            if m >= n:
                n = m
                WS, S = w + s , s

print(WS,S)