Problem:
 Score : 300 points    Problem Statement Snuke is making sugar water in a beaker.
Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.   Operation 1: Pour 100A grams of water into the beaker.  Operation 2: Pour 100B grams of water into the beaker.  Operation 3: Put C grams of sugar into the beaker.  Operation 4: Put D grams of sugar into the beaker.   In our experimental environment, E grams of sugar can dissolve into 100 grams of water.  Snuke will make sugar water with the highest possible density.  The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.
Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.
If there is more than one candidate, any of them will be accepted.  We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent.
Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.      Constraints  1 \leq A < B \leq 30  1 \leq C < D \leq 30  1 \leq E \leq 100  100A \leq F \leq 3  000  A , B , C , D , E and F are all integers.         Inputs Input is given from Standard Input in the following format:  A  B  C  D  E  F       Outputs Print two integers separated by a space.
The first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.        Sample Input 1 1 2 10 20 15 200      Sample Output 1 110 10  In this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.  We can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.
It is not possible to make sugar water with higher density.
For example, the following sequences of operations are infeasible:   If we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.  If we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.        Sample Input 2 1 2 1 2 100 1000      Sample Output 2 200 100  There are other acceptable outputs, such as:  400 200  However, the output below is not acceptable:  300 150  This is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.       Sample Input 3 17 19 22 26 55 2802      Sample Output 3 2634 934

Solution (Python):

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    A,B,C,D,E,F=MI()
    
    N=F//100+1
    dp=[[0]*(F+1) for _ in range(N)]
    
    dp[0][0]=1
    ansd=0
    ans=[100*A,0]
    
    AB=[A,B]
    CD=[C,D]
    
    for i in range(N):
        if dp[i][0]==1:
            for k in range(2):
                ii=i+AB[k]
                if ii<N:
                    dp[ii][0]=1
        for j in range(F+1):
            if dp[i][j]==1:
                for k in range(2):
                    jj=j+CD[k]
                    if jj<=F and i*100+jj<=F and jj<=E*i:
                        dp[i][jj]=1
                        d=jj/(100*i+jj)
                        if d>ansd:
                            ans=[100*i+jj,jj]
                            ansd=d
    print(' '.join(map(str, ans)))
    

    

main()

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


water = []
for i in range(f//a+1):
    for j in range(f//b+1):
        if a*i + b*j <= f and not (i == 0 and j == 0):
            water.append(a*i + b*j)
water = list(set(water))
            

sugar = []
for w in water:
    sugar.append(min(f - w, (w//100)*e))
    

ans = [water[0], 0]
max_conc = 0
for w, s in zip(water, sugar):
    for i in range(s//c+1):  
        j = (s - c*i)//d  
        cap = (c*i+d*j)  
        if (cap / (w + cap))*100 > max_conc:
            max_conc = (cap / (w + cap))*100
            ans = [w+cap, cap]
            
print(*ans)

Solution (Python):
A, B, C, D, E, F = map(int,input().split())
T = list(range(31))
ret = [100*A, 0]
for a in T:
  for b in T:
    SMax = min((A*a+B*b)*E,F-100*(A*a+B*b))
    for d in range(SMax//D+1):
      c = ( SMax - d*D ) // C
      S = C*c+D*d
      W = 100*(A*a+B*b) + S
      if (ret[1] * W) < (ret[0] * S):
        ret = [W,S]
print(*ret)

Solution (Python):
import math

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

ans = 0
ans1 = 0
ans2 = 0

for a in range(math.ceil(F / (A*100))+1):
  for b in range(math.ceil(F / (B*100))+1):
    for c in range(1000):
      for d in range(1000):
        if a == 0 and b == 0 and c == 0 and d == 0:
          continue
        
        if 100*A*a + 100*B*b + C*c + D*d > F:
          continue

        if (C*c)+(D*d) > E * (A*a+B*b):
          continue

        tmp = (C*c+D*d)*100 / (100*A*a + 100*B*b + C*c + D*d)
        if tmp > ans:
          ans = tmp
          ans1 = 100*A*a + 100*B*b + C*c + D*d
          ans2 = C*c + D*d

if ans2 == 0:
  print("{0} {1}".format(600, ans2))
else:
  print("{0} {1}".format(ans1, ans2))

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


rate = 0
water = 0
suger = 0

al = f // (a * 100)
bl = f // (b * 100)
for i in range(al + 1):
    for j in range(bl + 1):
        for k in range(100 + 1):
            for l in range(100 + 1):
                w = 100 * a * i + 100 * b * j
                s = c * k + d * l
                if w + s <= 0:
                    break
                temp = w + s
                r = (s * 100) / temp
                if temp <= f and (a * i + b * j) * e >= s:
                    if rate <= r:
                        water = w
                        suger = s 
                        rate = r
print(water + suger, suger)

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

max_A=F//(A*100)
for a in range(max_A+1):
    max_B=(F-100*A*a)//(B*100)
    for b in range(max_B+1):
        water=A*a+B*b
        max_sugar=min(F-water*100,water*E)
        max_c=max_sugar//C
        for c in range(max_c+1):
            max_d=(max_sugar-C*c)//D
            for d in range(max_d+1):
                sugar=C*c+D*d
                sugarwater=water*100+sugar
                if sugarwater==0:
                    pass
                elif sugar/(sugarwater) > max_dencity:
                    max_dencity=sugar/(sugarwater)
                    best_sugarwater=sugarwater
                    best_sugar=sugar
                    
                
print(best_sugarwater,best_sugar)

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

water=set()
for a in range(0,F+1,100*A):
  for b in range(0,F+1,100*B):
    if a+b<=F: water.add(a+b)
water=sorted(list(water))

suger=set()
for c in range(0,F+1,C):
  for d in range(0,F+1,D):
    if c+d<=F: suger.add(c+d)
suger=sorted(list(suger))

ans,answater,anssuger=0,0,0
for w in water:
  for s in suger:
    if (w//100)*E<s or w+s>F: break
    if w+s!=0:
      if ans<=(100*s)/(w+s):
        answater,anssuger=w+s,s
        ans=(100*s)/(w+s)
print(answater,anssuger)

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

xy = []

for Ai in range(0,F+1,100*A):
    for Bj in range(0,F-Ai+1,100*B):
        
        x = Ai + Bj

        
        for Ci in range(0,(F-x)+1,C):
            Dj = 0
            y = Ci + Dj
            while x + y <= F:
                xy.append((x,y))
                Dj += D
                y += D

ans = (100*A,0)
node = 0
for x,y in xy:
    if x == y == 0:
        continue
    
    if (x//100) * E >= y:
        tmp = 100*y/(x+y)
        
        if node < tmp:
            ans = (x+y, y)
            node = tmp

print(*ans)

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

xy = []
for Ai in range(0,F+1,100*A):
    for Bj in range(0,F-Ai+1,100*B):
        x = Ai + Bj
        for Ci in range(0,(F-x)+1,C):
            Dj = 0
            y = Ci + Dj
            while x + y <= F:
                xy.append((x,y))
                Dj += D
                y += D

ans = (100*A,0)
node = 0
for x,y in xy:
    if x == y == 0:
        continue
    if (x//100) * E >= y:
        tmp = 100*y/(x+y)
        if node < tmp:
            ans = (x+y, y)
            node = tmp

print(*ans)

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

a = 0
b = 0
c = 0
for s in range(F//A+2):
    for t in range(F//B+2):
        tempa = 100*(s*A + t*B)
        if tempa >= F or tempa == 0:
            continue
        for u in range((F-tempa)//C+2):
            for v in range((F-tempa)//D+2):
                tempb = u*C+v*D
                if tempa+tempb > F:
                    continue
                if tempb/(tempa+tempb) > E/(100+E):
                    continue
                if c < tempb/(tempa+tempb):
                    a = tempa
                    b = tempb
                    c = tempb/(tempa+tempb)
if a+b == 0:
    a = 100*A
print(a+b, b)

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

A *= 100
B *= 100
dp = [-1]*(F+1)
if A <= F:
    dp[A] = 0
if B <= F:
    dp[B] = 0
for i in range(A, F + 1):
    if A <= i:
        dp[i] = max(dp[i - A], dp[i])
    if B <= i:
        dp[i] = max(dp[i - B], dp[i])
    if C <= i and dp[i-C] >= 0:
        if dp[i-C] + C <= (i-C - dp[i-C]) * (E / 100):
            dp[i] = max(dp[i-C] + C, dp[i])
    if D <= i and dp[i-D] >= 0:
        if dp[i-D] + D <= (i - D - dp[i-D]) * (E / 100):
            dp[i] = max(dp[i-D] + D, dp[i])


x = 0
id = 0
for i in range(A, F+1):
    if x <= (dp[i] / (i)):
        x = dp[i] / (i)
        id = i
print(id, dp[id])

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


waterA = np.arange(31) * 100 * A
waterB = np.arange(31) * 100 * B
water = np.add.outer(waterA, waterB).flatten()
water = np.unique(water[water <= F])
water = water[np.nonzero(water)]


rest = F - water


can_solve = np.minimum(water * E // 100, rest)


sugarC = np.arange(101) * C
sugarD = np.arange(101) * D
sugar = np.add.outer(sugarC, sugarD).flatten()
sugar = np.unique(sugar[sugar <= F])
sugar.sort()

pos = np.searchsorted(sugar, can_solve, side="right") - 1
ans = np.argmax(sugar[pos] / (water + sugar[pos]))
print(sugar[pos[ans]] + water[ans], sugar[pos[ans]])

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

water=set()
for a in range(0,F+1,100*A):
  for b in range(0,F+1,100*B):
    if a+b<=F: water.add(a+b)
water=sorted(list(water))
suger=set()
for c in range(0,F+1,C):
  for d in range(0,F+1,D):
    if c+d<=F: suger.add(c+d)
suger=sorted(list(suger))

kosa,ans1,ans2=0,0,0
for w in water:
  for s in suger:
    if (w//100)*E<s or w+s>F: break
    if w+s!=0 and kosa<=(100*s) / (w+s):
      kosa=(100*s) / (w+s)
      ans1,ans2=w+s,s
print(ans1,ans2)

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

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

ans = [0, 0, -1]

for x in range((30 // A) + 1):
    for y in range((30 // B) + 1):
        if 100 * (A * x + B * y) > F or x + y == 0:
            continue
        a = 100 * (A * x + B * y)
        for z in range(1 + ((a // 100) * E) // C):
            b = C * z + D * (((a // 100) * E - C * z) // D)
            b_2 = C * z + D * ((F - (a + C * z)) // D)
            if b + a > F or b > (a // 100) * E:
                b = 0
            if b_2 + a > F or b_2 > (a // 100) * E:
                b_2 = 0
            b = max(b, b_2)
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]

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

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

list_water = []
list_suger = []
max_conc = (100 * E) / (100 + E)
ans_conc = 0

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

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

for i in list_water :
    for j in list_suger :
        if 0 < (i + j) <= F :
            concent = (100 * j) / (i + j)
            if ans_conc <= concent <= max_conc :
                ans_conc = concent
                ans = i + j
                ans_suger = j

print(ans, ans_suger)

Solution (Python):
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a,b,c,d,e,f = inm()
s = [False]*3001
for i in range(3001):
    for j in range(1501):
        k = c*i+d*j
        if k<=f:
            s[k] = True
w = [False]*32
for i in range(31):
    for j in range(16):
        k = a*i+b*j
        if 100*k<=f:
            w[k] = True
mx = 0.0
mxs = 0
mxsw = 100*a
for t in range(f-99):  
    if not s[t]:
        continue
    ww = t/e  
    for z in range(f//100 + 1, 0,-1):  
        if not w[z] or z*100+t>f:
            continue
        if z<ww:
            break
        r = t/(100*z+t)
        if r>mx:
            mx = r
            mxs = t
            mxsw = t+100*z
print("{} {}".format(mxsw,mxs))

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

def main():
    max_density = 0
    whole_weight = 0
    sugar_weight = 0
    A, B, C, D, E, F = map(int, input().split())
    for n_a in range(int(F / (100 * A)) + 1):
        for n_b in range(int((F - 100 * n_a * A) / (100 * B)) + 1):
            max_sugar = min(E * (n_a * A + n_b * B), F - 100 * (n_a * A + n_b * B))
            for n_c in range(int(max_sugar / C) + 1):
                for n_d in range(int((max_sugar - C * n_c) / D) + 1):
                    if 100 * (n_a * A + n_b * B) + n_c * C + n_d * D == 0:
                        continue
                    density = (n_c * C + n_d * D) / (100 * (n_a * A + n_b * B) + n_c * C + n_d * D)
                    if density > max_density or (density == 0 and max_density == 0):
                        max_density = density
                        whole_weight = 100 * (n_a * A + n_b * B) + n_c * C + n_d * D
                        sugar_weight = n_c * C + n_d * D

    print(whole_weight, sugar_weight)

if __name__ == '__main__':
    main()

Solution (Python):




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

water_set=set()
for i in range( F // (A*100) + 1):
    for j in range( F // (B*100) + 1 ):
        volume_water = i*(A*100) + j*(B*100)
        
        if volume_water < F and volume_water != 0:
            water_set.add( volume_water )
        
water_list=sorted(water_set)
max_concent = -1
materials=[]
for w in water_list:
    max_sugar = (w // 100) * E

    sugar_set=set()
    for i in range( max_sugar // C + 1 ):
        for j in range( max_sugar // D + 1 ):
            volume_sugar = (i*C) + (j*D)
            
            if volume_sugar <= max_sugar and (w + volume_sugar) <= F:
                sugar_set.add( volume_sugar )
 
    sugar_list=sorted(sugar_set)
    for s in sugar_list:
        concent = s / (w + s) * 100
        if concent > max_concent:
            max_concent = concent
            materials = [w,s]
    
print( (materials[0] + materials[1]) , materials[1])

Solution (Python):

import math



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

water_set=set()
for i in range( F // (A*100) + 1):
    for j in range( F // (B*100) + 1 ):
        volume_water = i*(A*100) + j*(B*100)
        
        if volume_water < F and volume_water != 0:
            water_set.add( volume_water )
        
water_list=sorted(water_set)


max_concent = -1
materials=[]
for w in water_list:
    max_sugar = (w // 100) * E

    for i in range( max_sugar // C + 1 ):
        for j in range( max_sugar // D + 1 ):
            volume_sugar = (i*C) + (j*D)
            
            if volume_sugar <= max_sugar and (w + volume_sugar) <= F:
                concent = volume_sugar / (w + volume_sugar) * 100
                if concent > max_concent:
                    max_concent = concent
                    materials = [w,volume_sugar]
            
print( (materials[0] + materials[1]) , materials[1])

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

water=set()
for a in range(0,F+1,100*A):
  for b in range(0,F+1,100*B):
    if a+b<=F: water.add(a+b)
water=sorted(list(water))

suger=set()
for c in range(0,F+1,C):
  for d in range(0,F+1,D):
    if c+d<=F: suger.add(c+d)
suger=sorted(list(suger))

ans,answater,anssuger=0,0,0
for w in water:
  for s in suger:
    if (w//100)*E<s or w+s>F: break
    if w+s!=0:
      if ans<=(100*s)/(w+s):
        answater,anssuger=w+s,s
        ans=(100*s)/(w+s)
print(answater,anssuger)

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

density = 0
max_density = 0
ans = []
for a in range(31):
    if a*A*100> F:
        break
    for b in range(31):
        if a==0 and b==0:
            continue
        if a*A*100+b*B*100>F:
            break
        for c in range(101):
            for d in range(101):
                density = 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D)


                if a*A*100+b*B*100*c*C+d*D>F:
                    break

                if ( a*A*100 + b*B*100 + c*C + d*D <= F ) and ( 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D) <= 100*E/(100+E) ):


                    if max_density <= density:

                        max_density = density
                        ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))


print(ans[-1])

Solution (Python):
A, B, C, D, E, F = map(int, input().split())
water = []
sugar = []
pct = -1
ans_sugar = 0
ans_tot = 0


for a in range(F + 1):
	if 100 * A * a > F: break
	for b in range(F + 1):
		x = 100 * A * a + 100 * B * b
		if x <= F:
			water.append(x)
			

for a in range(F + 1):
	if C * a > F: break
	for b in range(F + 1):
		x = C * a + D * b
		if x <= F:
			sugar.append(x)
			
for w in water:
	for s in sugar:
		if w + s == 0: continue
		if w + s <= F and E * w / 100 >= s:
			if pct < s / (w + s):
				pct = s / (w + s)
				ans_sugar = s
				ans_tot = w + s
				
print(ans_tot, end = " ")
print(ans_sugar)

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

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

water1=a
water2=b
sugar1=c
sugar2=d

from functools import lru_cache
@lru_cache(maxsize=None)
def solve(w,s,nokori):


    if nokori < 0:
        return [-1,w,s]

    max_s = w/100 * e

    if max_s >= s and w+s > 0:
        now = [100*s / (w+s),w,s]
    else:
        now=[-1,w,s]

    res1=solve(w+water1*100,s,nokori-water1*100)
    res2=solve(w+water2*100,s,nokori-water2*100)
    if max_s > s:
        res3=solve(w,s+sugar1,nokori-sugar1)
        res4=solve(w,s+sugar2,nokori-sugar2)
    else:
        res3=[-1,w,s]
        res4=[-1,w,s]

    lis = [now,res1,res2,res3,res4]
    lis.sort()

    return lis[-1]

ans = solve(0,0,f)
print(ans[1]+ans[2],ans[2])

Solution (Python):






a, b, c, d, e, f = list(map(int, input().split()))
ans_water = 1
ans_sugar = 0

for i_a in range(30+1):
    for i_b in range(15+1):
        water = 100 * a * i_a + 100 * b * i_b
        if water == 0:
            continue
        if water > f:
            continue
        for i_d in range(750+1):
            sugar = d * i_d
            if water + sugar > f:
                continue
            if sugar > water // 100 * e:
                continue
            sugar_max = water // 100 * e
            sugar_max = min(sugar_max, f - water)
            i_c = (sugar_max - sugar) // c

            
            
            
            
            
            
            
            sugar += i_c * c

            if sugar / water >= ans_sugar / ans_water:
                ans_sugar = sugar
                ans_water = water
                
                

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline

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

    dp = [[False] * (f+1) for _ in range(f+1)]
    dp[0][0] = True
    for i in range(f+1):
        for j in range(f+1):
            if dp[i][j]:
                if i + 100*a <= f:
                    dp[i+100*a][j] = True
                    if i + 100*b <= f:
                        dp[i+100*b][j] = True
                if j + c <= f and i+c <= f:
                    if ((i - j) / 100) * e >= (j+c):
                        dp[i+c][j+c] = True
                        if j + d <= f and i+d <= f:
                            if ((i - j) / 100) * e >= (j+d):
                                dp[i+d][j+d] = True

    M = 0
    sugar = 0
    con = -1
    for i in range(1, f+1):
        for j in range(f, -1, -1):
            if dp[i][j]:
                if j / i > con:
                    M = i
                    sugar = j
                    con = j/i
                break
    print(M, sugar)

if __name__ == '__main__':
    main()

Solution (Python):
A, B, C, D, E, F = [int(x) for x in input().split()]
a_water = 0
a_sugar = 0
a_conc = 0
max_conc = 100 * E / (100 + E)
for i in range(F//(100*A) + 1):
    for j in range((F-i*100*A)//(100*B) + 1):
        water = i * 100 * A + j * 100 * B
        if water == 0:
            continue
        for k in range((F-water)//C + 1):
            for l in range((F-water-C*k)//D + 1):
                sugar = k * C + l * D
                conc = 100 * sugar / (water + sugar) if water + sugar > 0 else 0
                if water + sugar <= F and conc <= max_conc and a_conc <= conc:
                    a_water = water
                    a_sugar = sugar
                    a_conc = conc
                else:
                    pass
print(a_water + a_sugar, a_sugar)

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

for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        water = (i * A + j * B) * 100
        rest = F - water
        if water > F:
            continue
        for k in range(rest // C + 1):
            for l in range(rest // D + 1):
                sugar = k * C + l * D
                if water + sugar > F:
                    continue
                if sugar * 100 > water * E:
                    continue
                if sugar + water == 0:
                    density = 0
                else:
                    density = sugar / (sugar + water)
                if maxDensity < density:
                    ans_water = water
                    ans_sugar = sugar
                    maxDensity = density


print(ans_water + ans_sugar, ans_sugar)

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

ans_omosa = 0
ans_sugar = 0
per_checker = 0

for _a in range(f // (a * 100)+1):
    for _b in range(f // (b * 100)+1):
        for _c in range((f // c)+1):
            for _d in range((f // d)+1):
                
                if (_c * c + _d * d) > (_a * a + _b * b) * e:
                    break
                
                elif (_c * c + _d * d) + (_a * a + _b * b) * 100 > f:
                    break
                elif (_a * a * 100 + _b * b * 100 + _c * c + _d * d) == 0:
                    break
                else:
                    if per_checker < (_c * c + _d * d) / (_a * a * 100 + _b * b * 100 + _c * c + _d * d):
                        per_checker = (_c * c + _d * d) / (_a * a * 100 + _b * b * 100 + _c * c + _d * d)
                        ans_omosa = (_c * c + _d * d) + (_a * a + _b * b) * 100
                        ans_sugar = (_c * c + _d * d)
                        

print("{} {}".format(max(a*100,ans_omosa), ans_sugar))

Solution (Python):
def rec_water(total):
    if total > F:
        return
    else:
        water_amount.append(total)
        rec_water(total+100*A)
        rec_water(total+100*B)











water_amount = []
sugar_amount = []
A, B, C, D, E, F = map(int, input().split())
rec_water(0)
for i in range(1501):
    for j in range(1501):
        sugar_amount.append(i*C+D*j)

water_amount = list(set(water_amount))
sugar_amount = list(set(sugar_amount))
water_amount.remove(0)

ans_sugar_water = min(water_amount)
ans_sugar = 0
percent = 0


for w in water_amount:
    for s in sugar_amount:
        if w+s > F or s > E*(w/100):
            continue
        else:
            
            if s / (w+s) > percent:
                ans_sugar_water = w+s
                ans_sugar = s
                percent = s / (w+s)
print(ans_sugar_water, ans_sugar)

Solution (Python):
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a,b,c,d,e,f = map(int,readline().split())
wf = f//100+1
water = [0]*(wf+31)
suger = [0]*(f+31)

water[0] = 1
suger[0] = 1

for i in range(wf):
    if water[i]:
        water[i+a] = 1
        water[i+b] = 1
for i in range(f):
    if suger[i]:
        suger[i+c] = 1
        suger[i+d] = 1

water = set(100*i for i in range(1,wf+1) if water[i])
suger = set(i for i in range(f+1) if suger[i])

ans_per = -1
ans_water = 0
ans_suger = 0

for w,s in itertools.product(water,suger):
    if w//100*e < s: 
        continue
    if w+s > f: 
        continue
    res = s/(w+s) 
    if res > ans_per:
        ans_per = res
        ans_water = w
        ans_suger = s

print(ans_water+ans_suger,ans_suger)

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

A*=100
B*=100

dp=[-1 for i in range(F+1)]
dp2=[-1 for i in range(F+1)]
dp[0]=0
dp2[0]=0


for i in range(1,len(dp)):
    if i>=C and dp[i-C]>=0 or i>=D and dp[i-D]>=0:
        dp[i]=i
for i in range(1,len(dp)):
    if i>=A and dp2[i-A]>=0 or i>=B and dp2[i-B]>=0:
        dp2[i]=i



noud=0
rep1=0
redp2=0
saidainoudo=E/(E+100)
for p1 in dp:
    if p1!=-1:
        for p2 in dp2:
            if p2>=0:

                satousui=p1+p2
                if 0<satousui<=F:
                    tempnoud=p1/(satousui)

                    if noud<tempnoud<=saidainoudo:
                        
                        noud=tempnoud
                        rep1=p1
                        redp2=satousui
if rep1>0:
    print(redp2,rep1)
else:
    print(A,0)

Solution (Python):
a, b, c, d, e, f = list(map(int, input().split()))
a_count = 0
b_count = 0
c_count = 0
d_count = 0
max_per = 0.0
max_ans = [a*100,0]
while a_count * 100 * a <= f:
    b_count = 0
    c_count = 0
    d_count = 0
    while (a_count * a + b_count * b) * 100  <= f:
        c_count = 0
        d_count = 0
        while (a_count * a + b_count * b) * 100 + c_count * c <= f:
            d_count = 0
            while (a_count * a + b_count * b) * 100 + c_count * c + d_count * d <= f:
                
                if (a_count * a + b_count * b)* e < (c_count * c + d_count * d):
                    break
                else:
                    if a_count + b_count + c_count + d_count == 0:
                        break
                    if max_per < (100 * (c_count * c + d_count * d) / ((a_count * a + b_count * b) * 100 + c_count * c + d_count * d)):
                        max_ans = [(a_count * a + b_count * b) * 100 + c_count*c + d_count*d, c_count*c + d_count * d]
                        max_per = (100 * (c_count * c + d_count * d) / ((a_count * a + b_count * b) * 100 + c_count * c + d_count * d))
                d_count += 1
            c_count += 1
        b_count += 1
    a_count += 1
print("{} {}".format(max_ans[0], max_ans[1]))

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):
        water.add(i+j)
water.remove(0)

sugar = set()
for i in range(0, f+1, c):
    for j in range(0, f+1, d):
        sugar.add(i+j)

best_w = best_s = best_dens = -1
for w in sorted(water):
    for s in sorted(sugar):
        if w + s > f:
            break
        if w * e < s * 100:
            break
        density = s / (s + w)
        if density > best_dens:
            best_w = w
            best_s = s
            best_dens = density

print(best_w + best_s, best_s)

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


dp = [0 for i in range(f//100+1)]
dp[0] = 1
for i in range(f//100+1):
    if dp[i]:
        if i + a <= f//100:
            dp[i+a] = 1
        if i + b <= f//100:
            dp[i+b] = 1
dd = [0 for i in range(f+1)]
dd[0] = 1
for i in range(f+1):
    if dd[i]:
        if i + c <= f:
            dd[i+c] = 1
        if i + d <= f:
            dd[i+d] = 1

water = [i for i in range(1,f//100+1) if dp[i]]
sugar = [i for i in range(f+1) if dd[i]]
ans = -1
ww, ss= 0,0
for w in water:
    for s in sugar:
        if w*100+s <= f and e*w >= s:
            if ans < 100 * s / (100*w+s):
                ans = 100*s / (w*100+s)
                ww,ss=w*100,s

print(ww+ss,ss)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    A, B, C, D, E, F = [int(x) for x in input().split()]

    b = [False] * 31
    b[A] = True
    b[B] = True

    for i, v in enumerate(b):
        if v:
            if i + A <= 30:
                b[i + A] = True
            if i + B <= 30:
                b[i + B] = True

    sugar = [False] * 3001
    sugar[C] = True
    sugar[D] = True

    for i, v in enumerate(sugar):
        if v:
            if i + C <= 3000:
                sugar[i + C] = True
            if i + D <= 3000:
                sugar[i + D] = True

    ans1 = A * 100
    ans2 = 0

    for i, v in enumerate(b):
        if v:
            for j, s in enumerate(sugar):
                if s:
                    if ans2 / (ans1 + ans2) < j / (i * 100 + j) <= E / (100 + E) and i * 100 + j <= F:
                        ans1 = i * 100
                        ans2 = j

    print(ans1 + ans2, ans2)





if __name__ == '__main__':
    main()

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

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