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):
from numba import njit
A, B, C, D, E, F = [int(_) for _ in input().split()]


@njit
def main(A, B, C, D, E, F):
    conc = -1
    ans = (1, 2)
    for na in range(F // (100 * A) + 1):
        for nb in range(F // (100 * B) + 1):
            if na == nb == 0:
                continue
            G = F - na * 100 * A - nb * 100 * B
            for nc in range(G // C + 1):
                for nd in range(G // D + 1):
                    W = na * 100 * A + nb * 100 * B + nc * C + nd * D
                    if 0 < W <= F and nc * C + nd * D <= E * (na * A + nb * B):
                        conc2 = 100 * (nc * C + nd * D) / W
                        if conc < conc2 <= 100 * E / (100 + E):
                            ans = (W, nc * C + nd * D)
                            conc = conc2
    return ans


print(*main(A, B, C, D, E, F))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



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

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*E//100+1), C):
			for s2 in range(0, min(F-w-s1+1, w*E//100-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):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



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

water = set()

for a in range(F//(100*A)+1):
	for b in range((F-100*a*A)//(100*B)+1):
		water.add(100*(a*A+b*B))

sugar = [0]*(F+1)
sugar[0] = 1
for i in range(1, F+1):
	sugar[i] = 0<(sugar[i-C]*(0<i) + sugar[i-D]*(0<i))

sugar_acc = [0]*(F+1)
tmp = 0
for i in range(F//2+1):
	if sugar[i] == 1:
		tmp = i
	sugar_acc[i] = tmp




ans = 0
den = 0
water_ans = 0
sugar_ans = 0
water = sorted(list(water))

for water_tmp in water[1:]:
	t = min(E*water_tmp//100, F-water_tmp)
	sugar_tmp = sugar_acc[t]
	den_tmp = sugar_tmp/(sugar_tmp+water_tmp)

	if den <= den_tmp:
		den = den_tmp
		water_ans = water_tmp
		sugar_ans = sugar_tmp

print(water_ans+sugar_ans, sugar_ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



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

water = set()

for a in range(F//(100*A)+1):
	for b in range((F-100*a*A)//(100*B)+1):
		water.add(100*(a*A+b*B))

sugar = [0]*(F+1)
sugar[0] = 1
for i in range(1, F+1):
	sugar[i] = 0<(sugar[i-C]*(0<i) + sugar[i-D]*(0<i))

sugar_acc = [0]*(F+1)
tmp = 0
for i in range(F//2+1):
	if sugar[i] == 1:
		tmp = i
	sugar_acc[i] = tmp




ans = 0
den = 0
water_ans = 0
sugar_ans = 0
water = sorted(list(water))

for water_tmp in water[1:]:
	t = min(E*water_tmp//100, F-water_tmp)
	sugar_tmp = sugar_acc[t]
	if F < sugar_tmp + water_tmp:
		continue
	den_tmp = sugar_tmp/(sugar_tmp+water_tmp)

	if den <= den_tmp:
		den = den_tmp
		water_ans = water_tmp
		sugar_ans = sugar_tmp

print(water_ans+sugar_ans, sugar_ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



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

water = set()

for a in range(F//(100*A)+1):
	for b in range((F-100*a*A)//(100*B)+1):
		water.add(100*(a*A+b*B))

sugar = [0]*(F+1)
sugar[0] = 1
for i in range(1, F+1):
	sugar[i] = 0<(sugar[i-C]*(0<i) + sugar[i-D]*(0<i))

"""
f = F//2
sugar = [0]*(F+1)
for c in range(f//C+1):
	for d in range((f-c*C)//D+1):
		sugar[c*C+d*D] = 1
print(sugar)
"""
sugar_acc = [0]*(F+1)
tmp = 0
for i in range(F//2+1):
	if sugar[i] == 1:
		tmp = i
	sugar_acc[i] = tmp




ans = 0
den = 0
water_ans = 0
sugar_ans = 0
water = sorted(list(water))

for water_tmp in water[1:]:
	if E == 100:
		t = min(water_tmp, F-water_tmp)
	else:
		t = min(E*water_tmp//100, F-water_tmp)

	sugar_tmp = sugar_acc[t]
	if F < sugar_tmp + water_tmp:
		continue

	if sugar_tmp == 0:
		den_tmp = 0
	else:
		den_tmp = sugar_tmp/(sugar_tmp+water_tmp)

	
	if den <= den_tmp:
		den = den_tmp
		water_ans = water_tmp
		sugar_ans = sugar_tmp

print(water_ans+sugar_ans, sugar_ans)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
water = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1,100*B):
        if i + j <= F:
            water.add(i + j)
water = list(water)
water.sort()
sugar = set()
for i in range(0,F+1,C):
    for j in range(0,F+1,D):
        if i + j <= F:
            sugar.add(i + j)
sugar = list(sugar)
sugar.sort()


ans = [[0,100*A,0]]
for i in water:
    for j in sugar:
        if i == 0 or j == 0:
            continue
        if i + j <= F and (i//100)*E >= j:
            
            ans.append([(100*j)/(i+j),i+j,j])
ans.sort()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



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

water = set()
sugar = [0]*(F+1)

for a in range(F//(100*A)+1):
	for b in range((F-100*a*A)//(100*B)+1):
		water.add(100*(a*A+b*B))

f = F//2
for c in range(f//C+1):
	for d in range((f-c*C)//D+1):
		sugar[c*C+d*D] = 1

sugar_acc = [0]*(F+1)
tmp = 0
for i in range(F//2+1):
	if sugar[i] == 1:
		tmp = i
	sugar_acc[i] = tmp




ans = 0
den = 0
water_ans = 0
sugar_ans = 0
water = sorted(list(water))

for water_tmp in water[1:]:
	if E == 100:
		t = min(water_tmp, F-water_tmp)
	else:
		t = min(E*water_tmp//100, F-water_tmp)

	sugar_tmp = sugar_acc[t]
	if F < sugar_tmp + water_tmp:
		continue

	if sugar_tmp == 0:
		den_tmp = 0
	else:
		den_tmp = sugar_tmp/(sugar_tmp+water_tmp)

	
	if den <= den_tmp:
		den = den_tmp
		water_ans = water_tmp
		sugar_ans = sugar_tmp

print(water_ans+sugar_ans, sugar_ans)

Solution (Python):
A,B,C,D,E,F = map(int,input().split())
mx =- 1
S = set()
W = set()

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

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

for w in W:
  for s in S:
    if 0<w+s<=F and s<=w*E//100:
      if mx<s/(w+s):
        ans=w+s,s
        mx=s/(w+s)

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

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

for i in range(31):
    for j in range(31):
        v = 100*A*i+100*B*j
        if v < F:
            a.append(v)
        else:
            break

for i in range(3000//C+2):
    for j in range(3000//D+2):
        v = C*i+D*j
        if v < F:
            b.append(v)
        else:
            break

a.sort()
b.sort()

c = -1
ans = [0, 0]
for ai in a:
    for bi in b:
        t = ai+bi
        if t > 0 and t <= F and (E*ai//100) >= bi:
            tc = 100*bi/(ai+bi)
            if c < tc:
                c = tc
                ans = [t, bi]

print(*ans)

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

for i in range(3001):
    for j in range(3001):
        v = 100*A*i+100*B*j
        if v <= F:
            a.append(v)
        else:
            break

for i in range(3001):
    for j in range(3001):
        v = C*i+D*j
        if v <= F:
            b.append(v)
        else:
            break

a.sort()
b.sort()

c = -1
ans = [0, 0]
for ai in a:
    for bi in b:
        t = ai+bi
        if t > 0 and t <= F and (E*ai//100) >= bi:
            tc = 100*bi/(ai+bi)
            if c < tc:
                c = tc
                ans = [t, bi]

print(*ans)

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

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

density = 0
ans = (100*A,0)
for i in range(30):  
    for j in range(30):  
        if i == 0 and j == 0:
            continue
        elif 100*(A*i+B*j) >= F:
            continue
        else:
            r = min(F-100*(A*i+B*j),E*(A*i+B*j))  
            a = r
            for k in range(C):
                s = r-D*k
                if s < 0:
                    break
                else:
                    a = min(a,s % C)
            if density < (r-a)/((r-a)+100*(A*i+B*j)):
                density = (r-a)/((r-a)+100*(A*i+B*j))
                ans = ((r-a)+100*(A*i+B*j),(r-a))

print(*ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    
    if e == 0 or min(a, b) == f:
        print(a, 0)
        sys.exit()

    water = [0] * 6001
    water[0] = True
    for i1 in range(3001):
        if water[i1]:
            water[i1 + a] = True
            water[i1 + b] = True
    sugar = [0] * 6001
    sugar[0] = True
    for i1 in range(3001):
        if sugar[i1]:
            sugar[i1 + c] = True
            sugar[i1 + d] = True

    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if water[i1]:
            for i2 in range(f + 1):
                if i1 + i2 > f:
                    break
                if sugar[i2]:
                    if i1 * e >= i2 * 100:
                        if noudo < i2 / (i1 + i2):
                            noudo = i2 / (i1 + i2)
                            r1 = int(i1 + i2)
                            r2 = int(i2)
                    else:
                        break
    if noudo == 0:
        print(a, 0)
    else:
        print(r1, r2)

if __name__ == '__main__':
    main()

Solution (Python):
A,B,C,D,E,F=map(int,input().split(' '))
water = set()
for a in range(0,F,100*A):
  for b in range(0,F,100*B):
    if a+b <= F:
      water.add(a+b)
    else:
      break
sugars = set()
for c in range(0,F,C):
  for d in range(0,F,D):
    if c+d <= F:
      sugars.add(c+d)
    else:
      break
density = 0
sugar = 0
content = 100*A
for x in water:
  for y in sugars:
    if x+y != 0 and x+y <= F and E*x >= 100*y and density < y/(x+y):
      density = y/(x+y)
      sugar = y
      content = x+y
print(content,sugar)

Solution (Python):

import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    A, B, C, D, E, F = read_values()
    W = set()
    
    for a in range(F // (A * 100) + 1):
        for b in range(F // (B * 100) + 1):
            w = a * 100 * A + b * 100 * B
            if 0 < w <= F:
                W.add(w)

    S = set()
    for c in range(F // C + 1):
        for d in range(F // D + 1):
            s = c * C + d * D
            if 0 <= s <= F:
                S.add(s)
    S = sorted(list(S))
    
    s, t = 0, 100 * A
    for w in W:
        p = min(F - w, math.ceil(E * w / 100))
        f = S[bisect.bisect_right(S, p) - 1]
        if f * 100 > E * w:
            continue

        if s * (w + f) < t * f:
            s, t = f, w + f
    print(t, s)


if __name__ == "__main__":
    main()

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

x = set()

for i in range(F):
  for j in range(F):
    water = 100 * A * i + 100 * B * j
    if F >=  water:
      x.add(water)
    else:
      break

sugar = water / 100 * E

y = set()

for i in range(F):
  for j in range(F):
    sugar = C * i + D * j
    if F >= sugar:
      y.add(sugar)
    else:
      break

x = list(x) 
y = list(y) 
percentage = 0
sugarWater = 0
ansSugar = 0

for i in range(len(x)):
  for j in range(len(y)):
    if x[i] + y[j] == 0:
      pass
    elif F >= x[i] + y[j]:
      if y[j] <= E * x[i] / 100:
        p = 100 * y[j] / ( x[i] + y[j] )
        if p >= percentage:
          percentage = p
          sugarWater = x[i] + y[j]
          ansSugar = y[j]

print(str(sugarWater) + " " + str(ansSugar))

Solution (Python):
import sys
import bisect
from fractions import Fraction

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

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

    water = set()
    for i in range(31):
        for j in range(31):
            t = i * A * 100 + j * B * 100
            if t <= F:
                water.add(t)
            else:
                break
    water = list(sorted(water))

    sugar = set()
    for i in range(3001):
        for j in range(3001):
            t = i * C + j * D
            if t <= F:
                sugar.add(t)
            else:
                break
    sugar = list(sorted(sugar))

    max_f = 0
    ans = (100 * A, 0)
    for w in water:
        for s in sugar:
            if w + s <= F and s <= (w // 100) * E and w + s != 0:
                if max_f < Fraction(s, w + s):
                    max_f = Fraction(s, w + s)
                    ans = (s + w, s)

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


if __name__ == '__main__':
    main()

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
Con = 0
a, b = 0, 0
for i in range(F//100 + 1):
    for j in range(F//100 + 1):
        Water = 100 * A * i + 100 * B * j
        if Water > F:
            break
        for x in range(E * Water // 100 + 1):
            for y in range(E * Water // 100 + 1):
                Sugar = C * x + D * y
                if Water + Sugar > F:
                    break
                if Water * E < Sugar * 100:
                    break
                if Sugar + Water == 0:
                    break
                c = (100 * Sugar) / (Sugar + Water)
                if Con <= c:
                    Con = c
                    a = Water
                    b = Sugar
print(a + b, b)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
inf=float("inf")
a*=100
b*=100
lst=[[inf,0] for _ in range(f//100)]
for i in range(f//b+1):
    for j in range(f//a+1):
        if i==0 and j==0:
            continue
        if (i*b+j*a)<=f:
            lst[(i*b+j*a)//100-1][0]=(i*b+j*a)
sugarlst=[]
C=max(c,d)
D=min(c,d)

for i in range(1500//C+1):
    for j in range((1500-i*C)//D+1):
        sugarlst.append(C*i+D*j)
sugarlst=set(sugarlst)
sugarlst=sorted(sugarlst)

for i in range(f//100):
    if lst[i][0]==inf:
        continue
    for j in sugarlst:
        weight=lst[i][0]+j
        if weight>f or (lst[i][0]//100)*e<j :
            break
        lst[i][1]=j

noudomax=0
for i in lst:
    noudo=i[1]/(i[0]+i[1])
    if noudo>=noudomax:
        ans=i
        noudomax=noudo
if noudomax==0:
    print(a,0)
else:
    print(ans[0]+ans[1],ans[1])

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
W = set(); S = set()
sa = 0; wsa = a * 100

for i in range(0, f + a * 100, a * 100):
    for j in range(0, f + b * 100, b * 100):
        w = i + j
        if w <= f:
            W.add(w)
        else:
            break
for i in range(0, f // 2 + c, c):
    for j in range(0, f // 2 + d, d):
        s = i + j
        if s <= f // 2:
            S.add(s)
        else:
            break
S.remove(0)
for i in W:
    for j in S:
        if e / (100 + e) >= j / (i + j) > sa / wsa and i + j <= f:
            sa, wsa = j, i + j
print(wsa, sa)

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  A,B,C,D,E,F=LI()
  ans_pair=[0,0]
  ans_noudo=0
  for a in range(31):
    for b in range(31):
      for c in range(3001):
        for d in range(3001):

          sato=c*C+d*D
          mizu=100*A*a+100*B*b
          satomizu=sato+mizu
          
          

          if satomizu==0:
            continue

          if F<satomizu:
            break

          noudo=(100*sato)/(satomizu)
          E_noudo=(100*E)/(100+E)
          if E_noudo<noudo:
            break

          if ans_noudo<=noudo:
            ans_noudo=noudo
            ans_pair=[satomizu,sato]
            

  return str(ans_pair[0])+' '+str(ans_pair[1])


print(main())

Solution (Python):

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

lim = (f // c) + 1
ans_n = 0
ans_total = 0
ans_su = 0

for ac in range(31):
    for bc in range(31):

        wt = a * ac * 100 + b * bc * 100
        if wt == 0:
            break

        max_su = wt / 100 * e

        for cc in range(lim):
            for dc in range(lim):

                su = c * cc + d * dc

                if (su > max_su) or (wt + su > f):
                    break

                n = (100 * su) / (wt + su)
                if n >= ans_n:
                    ans_n = n
                    ans_total = wt+su
                    ans_su = su

print(ans_total, ans_su)

Solution (Python):
from itertools import product

A,B,C,D,E,F = map(int, input().split())
num_a = F // (100 * A)
num_b = F // (100 * B) 
num_c = int((F * E / (E + 100)) // C)
num_d = int((F * E / (E + 100)) // D)

def check_w(w_mizu, w_sato, F):
  return w_mizu + w_sato <= F

def check_tokeru(w_mizu, w_sato, E):
  return 100 * w_sato / (w_mizu + w_sato) <= 100 * E / (100 + E)

def culc_density(w_mizu, w_sato):
  return 100 * w_sato / (w_mizu + w_sato)

max = [100 * A, 0, 0]  
for _a, _b,  in product(range(num_a + 1), range(num_b + 1)): 
  w_mizu = (A * _a + B * _b) * 100
  if w_mizu == 0 or w_mizu >= F:
    continue
    
  for _c, _d in product(range(num_c + 1), range(num_d + 1)):
    w_sato = (C * _c + D * _d)
    if w_sato == 0 or w_sato >= F or (w_mizu + w_sato) > F:
      continue
    
    density = culc_density(w_mizu, w_sato)
  
    if check_w(w_mizu, w_sato, F) and check_tokeru(w_mizu, w_sato, E):
      if max[2] < density:
        max[0] = w_mizu + w_sato
        max[1] = w_sato
        max[2] = density

if max[0]:
  print(max[0], max[1])

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

density = -1
s_water = -1
sugar = -1
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:
                    continue
                if w + s > F or w + s < 100*A:
                    continue
                if w/100 * E >= s:
                    tmp = 100*s / (w + s)
                    if tmp > density:
                        density = tmp
                        s_water = w + s
                        sugar = s
print(s_water, sugar)

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

ans = -1
ans_water = -1
ans_sugar = -1
for ia in range(f//(a*100)+2):
    water = 100*a*ia
    if water > f or water == 0: continue
    for ib in range(f//(b*100)+2):
        if ib != 0: water += 100*b
        if water > f or water == 0: continue
        for ic in range(f//c+1):
            sugar = c*ic
            if sugar/(water//100) > e: continue
            for id in range(f//d+1):
                if id != 0: sugar+=d
                if sugar/(water//100) > e: continue
                if sugar + water > f: continue
                if (100*sugar)/(sugar+water) > ans:
                    ans = (100*sugar)/(sugar+water)
                    ans_water = water
                    ans_sugar = sugar
print(ans_sugar+ans_water, ans_sugar)

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

water_masses = set()
for i in range(31):
    for j in range(31):
        mass = 100 * A * i + 100 * B * j
        if 0 < mass and mass <= F:
            water_masses.add(mass)

sugar_masses = set()
for i in range(3000 // C + C):
    for j in range(3000 // D + D):
        mass = C * i + D * j
        if mass <= F:
            sugar_masses.add(mass)

res_water = 100 * A
res_sugar = 0
for m_water in water_masses:
    for m_sugar in sugar_masses:
        if m_water + m_sugar > F:
            continue

        con = m_sugar / (m_water + m_sugar)
        if con <= (E / (100 + E)) and con > (res_sugar / (res_water + res_sugar)):
            res_water = m_water
            res_sugar = m_sugar


print(res_water + res_sugar, res_sugar)

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

ans = []
memo = []
for a in range(31):
    for b in range(31):
        for c in range(100):
            for d in range(100):
                w = 100 * A * a + 100 * B * b
                s = C * c + D * d
                if  w + s > F: continue
                if E * w / 100 >= s and w + s != 0:
                    ans.append(100 * s / (w + s))
                    memo.append([w + s, s])

print(*memo[ans.index(max(ans))])

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
g=[-1]*9999
g[a*100]=0
g[b*100]=0
h=[a*100,0]
p=0
for i in range(1,f+1):
    if g[i]==-1:
        continue
    if (g[i]+c)/(i-g[i])<=e*0.01:
        g[i+c]=max(g[i]+c,g[i+c])
    if (g[i]+d)/(i-g[i])<=e*0.01:
        g[i+d]=max(g[i]+d,g[i+d])
    g[i+a*100]=max(g[i+a*100],g[i])
    g[i+b*100]=max(g[i+b*100],g[i])
    if g[i]/i>p:
        p=g[i]/i
        h=[i,g[i]]
print(*h)

Solution (Python):
a,b,c,d,e,f=map(int,input().split())
ans=[-1]*9999
ans[a*100]=0
ans[b*100]=0
fin=[a*100,0]
p=0
for i in range(1,f+1):
    if ans[i]==-1:
        continue
    if (ans[i]+c)/(i-ans[i])<=e*0.01:
        ans[i+c]=max(ans[i]+c,ans[i+c])
    if (ans[i]+d)/(i-ans[i])<=e*0.01:
        ans[i+d]=max(ans[i]+d,ans[i+d])
    ans[i+a*100]=max(ans[i+a*100],ans[i])
    ans[i+b*100]=max(ans[i+b*100],ans[i])
    if ans[i]/i>p:
        p=ans[i]/i
        fin=[i,ans[i]]
print(*fin)

Solution (Python):
a,b,c,d,e,f = map(int,input().split())
ans = [-1]*10000

ans[a*100] = 0
ans[b*100] = 0
q1 = a*100
q2 = b*100
p = 0
fin = [a*100,0]
for i in range(1,f+1):
    if ans[i] == -1:
        continue
    if (ans[i]+c)/(i-ans[i]) <= e*0.01:
        ans[i+c] = max(ans[i]+c,ans[i+c])
    if (ans[i]+d)/(i-ans[i]) <= e*0.01:
        ans[i+d] = max(ans[i]+d,ans[i+d])
    ans[i+a*100] = max(ans[i+a*100],ans[i])
    ans[i+b*100] = max(ans[i+b*100],ans[i])
    if i != 0:
        if ans[i]/i > p:
            
            p = ans[i]/i
            fin = [i,ans[i]]

print(*fin)

Solution (Python):
from fractions import Fraction
from itertools import product

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

a_max = F // (A * 100)
b_max = F // (B * 100)

waters = set()

for a, b in product(range(0, a_max + 1), range(0, b_max + 1)):
    w = (a * A + b * B) * 100
    if w > F:
        continue

    waters.add(w)

waters = sorted(waters)[1:]
sugars = []

for w in sorted(waters):
    f1 = F - w
    f2 = w // 100 * E
    c_max = min(f1 // C, f2 // C)
    d_max = min(f1 // D, f2 // D)

    max_sugar = 0

    for c, d in product(range(0, c_max + 1), range(0, d_max + 1)):
        s = C * c + D * d
        if s > f1 or s > f2:
            continue
        max_sugar = max(max_sugar, s)

    sugars.append(max_sugar)

dense = [Fraction(s, s + w) for w, s in zip(waters, sugars)]

max_dense = 0
index = -1
for i, d in enumerate(dense):
    if d > max_dense:
        max_dense = d
        index = i

if index == -1:
    print(A * 100, 0)
else:
    print(waters[index] + sugars[index], sugars[index])

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

A,B,C,D,E,F = I()
lim1 = F//(100*A)
lim2 = F//(100*B)
ans = 0
ansnum = 0
for i in range(lim1+1):
    for j in range(lim2+1):
        w = 100*i*A+100*j*B
        if i == j == 0:
            continue
        if w > F:
            continue
        r = F-w
        num = 0
        lim3 = min(r,(i*A+j*B)*E)//C
        for k in range(lim3+1):
            num = max(num,k*C+((min(r,(i*A+j*B)*E)-k*C)//D)*D)
        if 100*num/(w+num) > ansnum:
            ans = [w+num,num]
            ansnum = 100*num/(w+num)
if ans == 0:
    print(A*100,0)
else:
    print(*ans)

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
W = set(); S = set()
sa = 0; wsa = a * 100
for i in range(0, f + a * 100, a * 100):
    for j in range(0, f + b * 100, b * 100):
        w = i + j
        if w <= f:
            W.add(w)
        else:
            break
for i in range(0, f // 2 + c, c):
    for j in range(0, f // 2 + d, d):
        s = i + j
        if s <= f // 2:
            S.add(s)
        else:
            break
S.remove(0)
for i in W:
    for j in S:
        if e / (100 + e) >= j / (i + j) > sa / wsa and i + j <= f:
            sa, wsa = j, i + j
print(wsa, sa)