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):
import itertools
A, B, C, D, E, F = map(int, input().split())
U = F
water = [0]*(U+1)
water[0] = 1
for i in range(U+1):
    if water[i]:
        if i+100*A <= U:
            water[i+100*A] = 1
        if i+100*B <= U:
            water[i+100*B] = 1
water_val = [val for val in range(1, U+1) if water[val]]
suger = [0]*(U+1)
suger[0] = 1
for i in range(U+1):
    if suger[i]:
        if i+C <= U:
            suger[i+C] = 1
        if i+D <= U:
            suger[i+D] = 1

suger_val = [val for val in range(U+1) if suger[val]]
max_c = -1
for w, s in itertools.product(water_val, suger_val):
    if E*w < 100*s:
        continue
    if F < w+s:
        continue

    if max_c < 100*s/(w+s):
        max_c = 100*s/(w+s)
        ans = (w+s, s)

print(*ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

a, b, c, d, e, f = MAP()
a *= 100
b *= 100
per = 0
ans = [str(a), '0']
for i in range(f // a + 1):
    for j in range((f - a * i) // b + 1):
        wtr = a * i + b * j
        rmn = f - wtr
        for k in range(rmn // c + 1):
            for l in range((rmn - c * k) // d + 1):
                sgr = c * k + d * l
                if wtr // 100 * e < sgr:
                    continue
                if wtr + sgr == 0:
                    continue
                tmp = 100 * sgr / (wtr + sgr)
                if wtr // 100 * e >= sgr and tmp > per:
                    per = tmp
                    ans = [str(wtr + sgr), str(sgr)]
print(' '.join(ans))

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
items = []
water = list(set([100*(A*w+B*x) for w in range(16)
                  for x in range(16) if A*w+B*x <= 30]))
water.sort()

for w in water:
    for x in range(1501):
        c = C*x
        i = (F-w-c)//D
        for y in reversed(range(i+1)):
            d = D*y
            if 0 < w+c+d <= F and w*E >= 100*(c+d):
                items.append((100*(c+d)/(w+c+d), w+c+d, c+d))
                break

items.sort(reverse=True)
print(items[0][1], items[0][2])

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

for w in range(16):
    for x in range(16):
        if w == x == 0:
            continue
        for y in range(1501):
            a = 100*A*w
            b = 100*B*x
            c = C*y
            i = (F-(a+b+c))//D
            for z in reversed(range(i+1)):
                d = D*z
                if a+b+c+d <= F and (a+b)*E >= (c+d)*100:
                    items.append((100*(c+d)/(a+b+c+d), a+b, c+d))
                    break

items.sort(reverse=True)

print(items[0][1]+items[0][2], items[0][2])

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:
    return a
  return gcd_(a,a % b) 
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""

"""def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g"""

def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7

def main():
  A,B,C,D,E,F = readInts()
  dic = {}
  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:
              mitudo = 100 * s / (w + s)
              dic[a,b,c,d] = mitudo
  maxV = max(dic.values())
  for k,v in dic.items():
    if v == maxV:
      print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3],C*k[2] + D*k[3])
      exit()
if __name__ == '__main__':
  main()

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

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

ans = 0
ans_ws = 0
ans_s = 0
for i in range(30//a+1):
    for j in range(30//b+1):
        w = 100*a*i+100*b*j
        s_max = f-w
        if s_max < 0:
            continue
        for k in range(s_max//c+1):
            temp = s_max - c*k
            if temp < 0:
                continue
            for l in range(temp//d+1):
                s = c*k + d*l
                if w+s == 0 or w+s > f:
                    continue
                else:
                    if 100*s > e*w:
                        continue
                    else:
                        x = (100*s)/(w+s)
                        if x >= ans:
                            ans = x
                            ans_ws = w+s
                            ans_s = s
print(ans_ws, ans_s)

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+b*j <= f//100:
            water.append(a*i+b*j)
water.pop(water.index(0))
water = list(set(water))
result = [[0,0,0]]
for w in water:
    for i in range(301):
        for j in range(301):
            sugar = c*i+d*j
            if sugar <= w*e and sugar+w*100 <= f: 
                result.append([100*sugar/(sugar+w*100), (sugar+w*100), sugar])
result.sort(reverse=True)
print(result[0][1], result[0][2])

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

def check_weight(a, b, c, d):
    if 100*A*a + 100*B*b + C*c + D*d <= F:
        return True
    else:
        return False

def check_conc(a, b, c, d):
    if C*c + D*d <= E * (A*a + B*b):
        return True
    else:
        return False

def check(a, b, c, d):
    if check_weight(a, b, c, d) and check_conc(a, b, c, d):
        return True
    else:
        return False

max_conc = 0
max_sugar_water = 0
max_sugar = 0

for a in range(F//(100*A) + 1):
    for b in range((F - 100*A*a)//(100*B) + 1):
        for c in range((F - 100*A*a - 100*B*b)//C + 1):
            for d in range((F - 100*A*a - 100*B*b - C*c)//D + 1):
                sugar = C*c + D*d
                water = 100*A*a + 100*B*b
                if water + sugar == 0:
                    continue
                if check(a, b, c, d) and max_conc <= 100*sugar/(water + sugar):
                    max_conc = 100*sugar/(water + sugar)
                    max_sugar = sugar
                    max_sugar_water = water + sugar

print(max_sugar_water, max_sugar)

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

ws = set()
for i in range(F+1):
    if 100*A*i > F: break
    for j in range(F+1):
        if 100*A*i + 100*B*j > F: break
        ws.add(100*A*i + 100*B*j)
ws.remove(0)
ss = set()
for i in range(F+1):
    if C*i > F: break
    for j in range(F+1):
        if C*i + D*j > F: break
        ss.add(C*i + D*j)

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

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+b*j)*100<=f:
            water.append(a*i+b*j)
water = list(set(water))

result = [[0,a*100,0]]
for i in water:
    for x in range(301):
        for y in range(301):
            if i > 0 and c*x+d*y > 0 and c*x+d*y<=i*e and (c*x+d*y+100*i)<=f:
                result.append([100*(c*x+d*y)/(c*x+d*y+100*i), c*x+d*y+100*i, c*x+d*y])

result.sort(reverse=True)
print(result[0][1], result[0][2])

Solution (Python):
from operator import itemgetter

A, B, C, D, E, F = list(map(int,input().split()))
X = []
ans = 1000
for i in range(31):
    for j in range(31):
        for k in range(51):
            for l in range(51):
                if 100*A*i+100*B*j+C*k+D*l != 0:
                    if 100*A*i+100*B*j+C*k+D*l <= F and (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l) <= E/(100 + E):
                        ans =(E/(100 + E) - (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l))
                        X.append([ans , 100*A*i+100*B*j+C*k+D*l, C*k+D*l])
X = sorted(X,key=itemgetter(0),reverse = False) 

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

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
kouho = []
for i in range(f // (100 * a) + 1):
    for j in range(f // (100 * b) + 1):
        water = 100 * (a * i + b * j)
        if water > f:
            break
        if water == 0:
            continue
        sugar_max = (a * i + b * j) * e
        for k in range(sugar_max // c + 1):
            for l in range(sugar_max // d + 1):
                sugar = c * k + d * l
                if water + sugar > f:
                    break
                if sugar > sugar_max:
                    break
                density = (sugar / (water + sugar), water + sugar, sugar)
                kouho.append(density)
kouho.sort(reverse=True)
print(kouho[0][1], kouho[0][2])

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

ans,index=0,[a*100,0]
base=100*e/(100+e)
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                w=i*100*a+j*100*b
                s=c*k+d*l
                if w==0:continue
                if w+s>f:break
                den=s*100/(w+s)
                if den<=base and ans<den:
                    ans=den
                    index=[w+s,s]

print(*index)

Solution (Python):
inf=10**8
a,b,c,d,e,f=map(int,input().split())
a,b=100*a,100*b
DP=[inf]*(f+max(a,b)+1)
DP[a],DP[b]=0,0

for i in range(f+1):
    if DP[i]!=inf:
        DP[i+a]=DP[i]
        DP[i+b]=DP[i]
        for j in c,d:
            if 100*(DP[i]+j)/(i+j)<=100*e/(100+e):
                DP[i+j]=max(DP[i],DP[i]+j)

ans,index=0,[a,0]
for i in range(f+1):
    if DP[i]!=inf:
        if ans<100*DP[i]/i:
            ans=100*DP[i]/i
            index=[i,DP[i]]

print(*index)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

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

wa = [0 for i in range(f+1)]
su = [0 for i in range(f+1)]

wa[0] = 1
su[0] = 1


for i in range(f//100 + 1):
    if i*100 + a*100 <= f:
        wa[i*100 + a*100] = max(wa[i*100 + a*100],wa[i*100])
    if i*100 + b*100 <= f:
        wa[i*100 + b*100] = max(wa[i*100 + b*100],wa[i*100])

for i in range(f + 1):
    if i+c <= f:
        su[i + c] = max(su[i + c],su[i])

    if i+d <= f:
        su[i + d] = max(su[i + d],su[i])



po = []

for i in range(1,f+1):
    for j in range(f+1):
        if i+j <= f and wa[i] and su[j] and (i //100) * e >= j:
            po.append([(100*j)/(i+j),i+j,j])

po.sort(reverse = True)


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

Solution (Python):
from decimal import Decimal as D
mi1,mi2,sa1,sa2,houwa,lim=map(int,input().split())
slim=houwa*lim//(100+houwa)
ws=set(mi1*i+mi2*j for i in range(lim//(100*mi1)+2) for j in range(lim//(100*mi2)+2) if 100*(mi1*i+mi2*j)<=lim)
ss=set(sa1*i+sa2*j for i in range(slim//sa1+2) for j in range(slim//sa2+2) if (sa1*i+sa2*j)<=slim)
ans=D("0")
iw,isa=mi1,0
for s in ss:
  for w in ws:
    if s>houwa*w or w==0:continue
    if ans<D(str(10000*s))/D(str(s+100*w)) and s+100*w<=lim:
      ans=D(str(10000*s))/D(str(s+100*w))
      isa,iw=s,w
print(100*iw+isa,isa)

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

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

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

p = e*100/(100+e)
a*=100
b*=100
ans = [a,0,0]

h = f//a
for i in range(h+1):
    w = (f-a*i)//b
    for j in range(w+1):
        q = f-a*i-b*j
        v = q//c
        for k in range(v+1):
            u = (q-c*k)//d
            for l in range(u+1):
                if c*k+d*l+a*i+b*j == 0:
                    continue
                n = (c*k+d*l)*100/(c*k+d*l+a*i+b*j)
                if n <= p and ans[2] < n:
                    ans = [c*k+d*l+a*i+b*j,c*k+d*l,n]

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

Solution (Python):
import bisect
a,b,c,d,e,f = map(int,input().split())
water = set()
sugar = set()
for i in range(301):
    for j in range(301):
        if 0 < (i*a + j*b)*100 <= f:
            water.add((i*a + j*b)*100)
for i in range(1500//d + 1):
    for j in range((1500 - (i*d))//c + 1):
        if i*d + j*c <= f//2 + 1:
            sugar.add(i*d + j*c)
sugar = sorted(list(sugar))
ans = [100*a, 0]
M = 0
for i in water:
    tmp = [i, sugar[bisect.bisect(sugar,min(f-i, i*e/100)) - 1]]
    if tmp[1]/sum(tmp) > ans[1]/ans[0]:
        ans = [sum(tmp), tmp[1]]
print(' '.join([str(i) for i in ans]))

Solution (Python):
import itertools

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

water, sugar = set(), set()
for a, b in itertools.product(range(F // (100 * A) + 1),
                              range(F // (100 * B) + 1)):
    tmp = 100 * A * a + 100 * B * b
    if 0 < tmp <= F:
        water.add(tmp)

for c, d in itertools.product(range(F // C + 1),
                              range(F // D + 1)):
    tmp = C * c + D * d
    if tmp <= F:
        sugar.add(tmp)

conc_max = 0
ans_w, ans_s = 100 * A, 0
for w, s in itertools.product(water, sugar):
    if w + s > F or w // 100 * E < s:
        continue
    conc = 100 * s / (w + s)
    if conc > conc_max:
        conc_max = conc
        ans_w, ans_s = w + s, s
print(ans_w, ans_s)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b, c, d, e, f = map(int, readline().split())
A = 100 * a
B = 100 * b
E = e / (100 + e)
ans = [0, 0]
check = 0
for i in range(f // A + 2):
    for j in range(f // B + 2):
        w = A * i + B * j
        for k in range(int((w * E) // c) + 2):
            for l in range(int((w * E) // d) + 2):
                if k == 0 and l == 0:
                    continue
                s = c * k + d * l
                n = s / (w + s)
                if w + s > f or n > E:
                    break
                if n > check:
                    ans = w + s, s
                    check = n
                    if check == E:
                        print(*ans)
                        exit()
if ans[0] == 0:
    print(100 * a, ans[1])
else:
    print(*ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b, c, d, e, f = map(int, readline().split())
A = 100 * a
B = 100 * b
E = 100 * e / (100 + e)
ans = [0, 0]
check = 0
for i in range(f // A + 2):
    for j in range(f // B + 2):
        w = A * i + B * j
        for k in range(int((w * E / 100) // c) + 2):
            for l in range(int((w * E / 100) // d) + 2):
                if k == 0 and l == 0:
                    continue
                s = c * k + d * l
                n = 100 * s / (w + s)
                if w + s > f or n > E:
                    break
                if n > check:
                    ans = w + s, s
                    check = n
if ans[0] == 0:
    print(100 * a, ans[1])
else:
    print(*ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b, c, d, e, f = map(int, readline().split())
ans = [0, 0]
check = 0
S = set()
W = set()
for i in range(31):
    for j in range(31):
        if 100 * a * i + 100 * b * j <= f:
            W.add(100 * a * i + 100 * b * j)
for i in range(1501):
    for j in range(1501):
        if c * i + d * j <= f:
            S.add(c * i + d * j)
W = sorted(list(W))
S = sorted(list(S))
for w in W:
    for s in S:
        if w == 0:
            continue
        n = 100 * s / (w + s)
        if w + s > f or s > e * (w / 100):
            break
        if n > check:
            ans = w + s, s
            check = n
if ans[0] == 0:
    print(100 * a, ans[1])
else:
    print(*ans)

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

water=set()
sugar=set()

for i in range(31):
    for j in range(31):
        if 100*i*a+100*j*b<=f:
            water.add(100*i*a+100*j*b)

for i in range(1501):
    for j in range(1501):
        if c*i+d*j<=f:
            sugar.add(c*i+d*j)
water=sorted(list(water))


sugar=sorted(list(sugar))

ans=0
sugarans=0
sumans=0
for i in range(1,len(water)):
    for j in range(len(sugar)):
        if water[i]+sugar[j]<=f and sugar[j]<=e*(water[i]/100):
            if ans<(100*sugar[j])/(water[i]+sugar[j]):
                
                ans=(100*sugar[j])/(water[i]+sugar[j])
                sugarans=sugar[j]
                sumans=water[i]+sugar[j]
               
if  sumans==0:
    print(100*a,sugarans)
else:
    print(sumans,sugarans)

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

memo = {}
memo.update(density=0, sugerwater=0, suger=0)
for a in range(F//(100*A) + 1):
    for b in range(F//(100*B) + 1):
        for c in range(E*(A*a + B*b)//C + 1):
            for d in range(E*(A*a + B*b)//D + 1):
                
                if 100 * (A * a + B * b) + C * c + D * d <= F and C * c + D * d <= E * (A * a + B * b) and (100 * (A * a + B * b) + C * c + D * d) != 0:
                    dens_tmp = 100*(C*c + D*d)/(100*(A*a + B*b) + C*c + D*d)
                    if dens_tmp >= memo['density']:
                        memo.update(density=dens_tmp, sugerwater=100 *
                                    (A * a + B * b) + C * c + D * d, suger=C * c + D * d)

print(memo['sugerwater'], memo['suger'])

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

indxmax=0.0
wmax=0
emax=0
elimit=(100*e)/(100+e)
c31=int(f/c)+1
for ai in range(0,f+1,100*a):
    for bi in range(0,f-ai+1,100*b):
        w=ai+bi

        if w<=f and w>0:
            c31=(w*e)//100+c
            for ci in range(0,c31,c):


                di=int(max(0,(min(f-w-ci,e*w/100-ci)//d)*d))

                indx=(ci+di)*100/w
                if indxmax<indx and e-indx>=0.0 and w+ci+di<=f:
                    wmax=w+ci+di
                    indxmax=indx 
                    emax=ci+di

if wmax>0:
    print(wmax,emax)
else:
    print(100*a,emax)

Solution (Python):
S = input().split(" ")
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
E = int(S[4])
F = int(S[5])

def calculate(a, b, c, d, e, f):
    result = []

    memo = {}

    for x in range(0,31):
        for y in range(0,31):
            if a * x * 100 + b * y * 100 <= F:
                result.append([x, y])

    finalResult = []
    memo = {}

    for res in result:
        waterValue = res[0] * 100 * a + res[1] * 100 * b
        for m in range(0, 101):
            for n in range(0, 101):

                sugerValue = m * c + n * d

                if waterValue + sugerValue == 0:
                    break

                if waterValue + sugerValue > f:
                    break

                if (waterValue / 100 * e) < sugerValue:
                    break

                nondu = (sugerValue * 100) / (sugerValue + waterValue)
                memo[res[0],res[1],m,n] = nondu



    maxNonDu = max(memo.values())

    for k,v in memo.items():
        if v == maxNonDu:
            print(k[0]*a*100+k[1]*b*100+k[2]*c+k[3]*d,k[2]*c+k[3]*d)
            break

    memo.values()

calculate(A, B, C, D, E, F)

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

max_w = 0
max_s = 0
dens = 0
for a in range((F//(100*A))+1):
    for b in range((F//(100*B))+1):
        for c in range((F//C)+1):
            for d in range((F//D)+1):
                if 100*(A*a+B*b) + c*C + d*D > F:
                    break
                elif (c*C+d*D) <= (A*a+B*b)*E and 100*(A*a+B*b) != 0:
                    temp_dens = (C*c+D*d)/(C*c+D*d+100*(A*a+B*b))
                    if temp_dens >= dens:
                        max_w = 100*(A*a+B*b)
                        max_s = C*c + D*d
                        dens = temp_dens
                    
print(max_w + max_s, max_s)

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

indxmax=0.0
wmax=0
emax=0
elimit=(100*e)/(100+e)
c31=int(f/c)+1
for ai in range(0,f+1,a):
    for bi in range(0,f-ai+1,b):
        w=100*ai+100*bi

        if w<=f and w>0:



            c31=(w*e)//100+c
            for ci in range(0,c31,c):

                for di in range(0,c31-ci,d):
                    indx=(ci+di)*100/w
                    if indxmax<indx and e-indx>=0.0 and w+ci+di<=f:
                        wmax=w+ci+di
                        indxmax=indx 
                        emax=ci+di

if wmax>0:
    print(wmax,emax)
else:
    print(100*a,emax)

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

candicate=[]
for weia in range(0,F+1,100*A):
    for weib in range(0,F+1,100*B):
        water=weia + weib
        if 0 <water <= F:
            salm=water//100*E
            for salc in range(0,salm+1,C):
                for sald in range(0,salm+1,D):
                    salt=salc+sald
                    if salt <= salm and water+salt <= F:
                        
                        candicate.append((water, salt))

max_pair=max(candicate, key=lambda x:x[1]/sum(x))

print(sum(max_pair), max_pair[1])

Solution (Python):

A,B,C,D,E,F = map(int,input().split())
water = set()
for water1 in range(0,F+1,100*A):
    for water2 in range(0,F+1,100*B):
        if water1 + water2 <= F:
            water.add(water1+water2)

sugar = set()
for sugar1 in range(0,F+1,C):
    for sugar2 in range(0,F+1,D):
        if sugar1 + sugar2 <= F:
            sugar.add(sugar1+sugar2)


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

if ans_s == 0 and ans_w == 0:
    ans_w = 100*A
print(ans_w+ans_s,ans_s)

Solution (Python):




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

    A *= 100
    B *= 100

    water = []
    sugar = []

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

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

    max_sugar_percent = 0
    max_water = 0
    max_sugar = 0

    water.sort()
    sugar.sort()

    for w in water:
        for s in sugar:
            if w + s > F:
                break

            if s > E * w / 100:
                break

            sugar_percent = w and(100 * s) / (w + s)
            if sugar_percent >= max_sugar_percent:
                max_sugar_percent = sugar_percent
                max_sugar = s
                max_water = w + s

    print(max_water, max_sugar)


if __name__ == "__main__":
    main()

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


for a in range(1 + F // 100):
    for b in range(1 + F // 100):
        water = 100 * (a * A + b * B)
        if 0 < water <= F:
            W.append(water)


for c in range(1 + F // C):
    for d in range(1 + F // D):
        sugar = c * C + d * D
        if sugar <= F:
            S.append(sugar)

W = list(set(W))
S = list(set(S))

x = -1
for w in W:
    for s in S:
        if w + s <= F:
            sol = 100 * s / w
            if x < sol <= E:
                x = sol
                X, Y = w + s, s

print(X,Y)

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

weight = 100 * A
suger = 0
den = 0
for a in range(0, F + 1, 100 * A):
    for b in range(0, F - a + 1, 100 * B):
        w = a + b
        if w == 0:
            continue
        S = E * w // 100
        for c in range(0, S + 1, C):
            for d in range(0, S - c + 1, D):
                s = c + d
                if w > 0 and w + s <= F and w * E >= s * 100:
                    tden = s / w
                    if den < tden:
                        weight = s + w
                        suger = s
                        den = tden

print(weight, suger)

Solution (Python):
a,b,c,d,e,f=[int(x) for x in input().split()]

ans=0
ans_s=0
ans_all=100*a
wlist=[]
slist=[]
for i in range(f//(100*a)+1):
    for j in range((f-i*100*a)//(100*b)+1):
        wlist.append(100*a*i+100*b*j)
for i in range((f*e//100)//c+1):
    for j in range((f*e//100)//d+1):
        slist.append(c*i+d*j)
wlist=set(wlist)
slist=set(slist)
for w in wlist:
    for s in slist:
        if w+s==0:break
        if s*100/(w+s)>ans and w*e/100>=s and w+s<=f:
            ans=s*100/(w+s)
            ans_s=s
            ans_all=w+s
print(ans_all,ans_s)

Solution (Python):

from bisect import bisect_left, bisect_right
a, b, c, d, e, f = map(int, input().split())
water = set()
sugar = set()
for i in range(30):
    for j in range(30):
        if 0 < (a * i + b * j) * 100 <= f:
            water.add((a * i + b * j) * 100)
for i in range(f//c + 1):
    for j in range(f//d + 1):
        if 0 < (c * i + d * j) <= f:
            sugar.add(c * i + d * j)
water = sorted(list(water))
sugar = sorted(list(sugar))
ans = [100 * a, 0]
for w in water:
    x = min(w * e // 100, f - w)
    if bisect_right(sugar, x) == 0:
        continue
    s = sugar[bisect_right(sugar, x) - 1]
    if ans[1] * (s + w) < s * ans[0]:
        ans = [s+w, s]
print(*ans)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
dp=[0]*(3000+1)
for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j<=3000:
            dp[c*i+d*j]=c*i+d*j
for i in range(1,3001):
    dp[i]=max(dp[i],dp[i-1])
ans_den=min(100*a,100*b)
ans_num=0
ans=0
for i in range(f//a+1):
    for j in range(f//b+1):
        
        w=100*i*a+100*j*b
        if w>f or w==0:
            continue
        rem=f-w
        sugar_max=min(e*(i*a+j*b),rem)
        val=dp[sugar_max]
        if val/(w+val)>ans:
            ans=val/(w+val)
            ans_num=val
            ans_den=w+val
print(ans_den,ans_num)