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



Sample input:
1 2 10 20 15 200


Sample output:
110 10

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    A_enable = []
    B_enable = []
    AB_enable = []
    a = 0
    while a <= F:
        A_enable.append(a)
        a += A*100
    
    b = 0
    while b <= F:
        B_enable.append(b)
        b += B*100

    for aa in A_enable:
        for bb in B_enable:
            if aa+bb<=F:
                AB_enable.append(aa+bb)
    AB_enable = sorted(list(set(AB_enable)))
    AB_enable.pop(0)

    C_enable = []
    D_enable = []
    CD_enable = []
    c = 0
    while c <= F:
        C_enable.append(c)
        c += C
    d = 0
    while d <= F:
        D_enable.append(d)
        d += D

    for cc in C_enable:
        for dd in D_enable:
            if cc+dd <= F:
                CD_enable.append(cc+dd)
    CD_enable = sorted(list(set(CD_enable)))
    CD_enable.pop(0)

    answer = [AB_enable[0],0,0] 

    for aabb in AB_enable:
        for ccdd in CD_enable:
            if (aabb/100)*E >= ccdd and aabb+ccdd<=F and answer[2] < ccdd/(aabb+ccdd): 
                
                answer[0] = aabb
                answer[1] = ccdd
                answer[2] = ccdd/(aabb+ccdd)
    
    print(answer[0]+answer[1], answer[1])
            
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
w_m=int((f*100/(100+e)))//100*100
s_m=f*e//(100+e)
answ=100*a
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if i==0 and j==0:
            w=min(100*a,100*b)
            s_m=f-w
        for k in range(s_m//c+1):
            for l in range((s_m-k*c)//d+1):
                s=k*c+l*d
                if (anss*(s+w)<s*(anss+answ)) and (s*(100+e)<=e*(s+w)):
                    answ=w
                    anss=s
print(answ+anss,anss)

Submission status: Accepted

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

water_list = []
suger_list = []

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

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

ans = 0
ans_list = []

for water in water_list:
  for suger in suger_list:
    if water != 0 and suger != 0:
      if suger/(water + suger) >= ans and water+suger <= F and suger <= (water/100)*E:
        ans = suger/(water + suger)
        ans_list = [water,suger]

if ans != 0:
  print(str(ans_list[0]+ans_list[1]) + " " + str(ans_list[1]))
else:
  print(str(A*100) + " 0")

Submission status: Accepted

Solution code:
a,b,c,d,e,f=[int(x) for x in input().split()]
a=100*a
b=100*b
ans = 0
v = 0
su = 0
for i in range(f//a+1):
  for j in range((f-a*i)//b+1):
    for k in range((e*(i*a//100+j*b//100))//c+1):
      for l in range((e*(a*i//100+j*b//100)-k*c)//d+1):
        if (i!=0 or j!=0 or k!=0 or l!=0) and ans<=(c*k+l*d)/(a*i+b*j+c*k+l*d) and (a*i+b*j+c*k+l*d)<=f:
          ans=(c*k+l*d)/(a*i+b*j+c*k+l*d)
          v = (a*i+b*j+c*k+l*d)
          su = c*k+l*d
print(v,su)

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_set = [0, 0, 0]

max_a = f // (a*100)
for i in range(max_a + 1):
  max_b = (f- i*a*100) // (b*100)
  for j in range(max_b + 1):
    water = i*a*100 + j*b*100
    if water == 0:
      continue
    suger = min(e * (water /100), f - water)
    max_c = int(suger // c)
    for k in range(max_c + 1):
      l = (suger - k * c) // d
      if (k*c + l*d) / water > (e / 100):
        continue
      if max_set[0] < (k*c + l*d) / water:
        max_set[0] = (k*c + l*d) / water
        max_set[1] = int((k*c + l*d) + water)
        max_set[2] = int((k*c + l*d))

if max_set[0] == 0 and max_set[1] == 0:
  print(100*a, 0)
else:
  print("{} {}".format(max_set[1], max_set[2]))

Submission status: Accepted

Solution code:
A,B,C,D,E,F=map(int,input().split())
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)
S=set()
for c in range(0,F+1,C):
    for d in range(0,F+1-c,D):
        S.add(c+d)
mx=-1
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])

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
tres = -1
res = [0,0]
for i in range(31):
    mass = i * 100*b
    if mass > f:
        break
    for j in range(31):
        mass = i * 100*b+100*a*j
        if mass > f:
            break
        if mass == 0:
            continue
        for k in range(101):
            mass = i * 100*b+100*a*j + k*d
            sugar = k*d
            if mass > f:break
            l = min(int((mass - sugar)*e/100 - k*d)//c, (f - mass)//c)
            if l < 0: break
            mass += l * c
            sugar += l*c
            noudo = sugar / mass
            if noudo > tres:
                tres = noudo
                res[0] = mass
                res[1] = sugar
                
print(" ".join(map(str,res)))

Submission status: Accepted

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

dic_w={}
i=0
while True:
    if (a*i*100)>f:
        break
    j=0
    while True:
        w=(a*i+b*j)*100
        if w==0:
            j+=1
            continue
        if w>f:
            break
        else:
            dic_w[w]=dic_w.get(w,0)+1
        j+=1
    i+=1
list_w=list(dic_w.keys())
list_w.sort()

dic_s={}
max_s=int(e*f/(100+e)+1)
i=0
while True:
    if c*i>max_s:
        break
    j=0
    while True:
        s=c*i+d*j
        if s>max_s:
            break
        else:
            dic_s[s]=dic_s.get(s,0)+1
        j+=1
    i+=1
list_s=list(dic_s.keys())
list_s.sort()

max_per=0
flag=False
ans_w=0
ans_s=0
for w in list_w:
    if flag==True:
        break
    for s in list_s:
        if s/(w/100)==e and s+w<=f:
            ans_w=w
            ans_s=s
            flag=True
            break
        if s/(w/100)>e:
            break
        if 100*s/(s+w)>=max_per and s+w<=f:
            ans_w=w
            ans_s=s
            max_per=100*s/(s+w)
print('{} {}'.format(ans_w+ans_s,ans_s))

Submission status: Accepted

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

water = []
sugar =[]
ans = [-1] * 3
for i in range(F+1):
    for j in range(F+1):
        y = i * C + j * D
        if y <= F:
            sugar.append(y)

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

for i in range(len(water)):
    for j in range(len(sugar)):
        a = water[i]
        b = sugar[j]
        if a + b <= F and a / 100 * E >= b:
            if ans[0] * (a + b) < 100 * b:
                ans[0] = 100 * b / (a + b)
                ans[1] = a + b
                ans[2] = b
print("{} {}".format(ans[1], ans[2]))

Submission status: Accepted

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

res = [100 * a, 0]
for x0 in range(31):
    for x1 in range(16):
        for x3 in range(1501):
            t1 = e*a*x0+e*b*x1-d*x3
            t2 = f-100*a*x0-100*b*x1-d*x3
            x2 = min(t1,t2) // c
            if x2 >= 0 and \
                (c*x2+d*x3)*res[0]-(100*a*x0+100*b*x1+c*x2+d*x3)*res[1]>0:
                res[0] = 100*a*x0+100*b*x1+c*x2+d*x3
                res[1] = c*x2+d*x3

print('{f} {s}'.format(f=res[0],s=res[1]))

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
p = -1
a = [0,0]

for i in range(0,F+1,A*100):
    for j in range(0,F+1-i,B*100):
        for k in range(0,int(E*(i+j)/100)+1,C):
            for l in range(0,int(E*(i+j)/100)+1-k,D):
                if i+j+k+l > F:
                    continue
                if i+j > 0 and p < (k+l) / (i+j+k+l):
                    p = (k+l) / (i+j+k+l)
                    a = [i+j+k+l,k+l]
print(a[0],a[1])

Submission status: Accepted

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

n_sugar = set()
max_sugar = math.ceil(E*F/100)
for i in range(max_sugar//C + 1):
    for j in range(max_sugar//D + 1):
        if C*i + D*j <= max_sugar:
            n_sugar.add(C*i + D*j)
            
n_water = set()
for i in range(F//(100*A) + 1):
    for j in range(F//(100*B) +1):
        if 100*A*i + 100*B*j <= F:
            n_water.add(100*A*i + 100*B*j)
            
n_sugar = list(n_sugar)
n_water.remove(0)
n_water = list(n_water)

ans_list = []
for sugar in n_sugar:
    for water in n_water:
        if sugar + water <= F and sugar <= E*water/100:
            ans_list.append([sugar+water, sugar, sugar/(sugar+water)])
            
ans_list = sorted(ans_list, key = lambda x: x[2], reverse = True)

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

Submission status: Accepted

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

G = F//100
water = []
for W in range(A,G+1):
    for a in range(G//A+1):
        for b in range(G//B +1):
            if a*A+b*B == W:
                water.append(W)

noudo = 0
ans = (100*A,0)

for W in water:
    sugerlimit = min(W*E,F-100*W)
    for c in range(sugerlimit//C,-1,-1):
        for d in range(sugerlimit//D,-1,-1):
            if c*C+d*D > sugerlimit:
                pass
            else:
                noudo2 = 100*(c*C+d*D)/(100*W+c*C+d*D)
                if noudo2>noudo:
                    ans = (100*W+c*C+d*D,c*C+d*D)
                    noudo = noudo2
                break

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

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
cmax = 0
x = 100*A
y = 0
for n in range(F//(100*A)+1):
    for m in range((F-n*100*A)//(100*B)+1):
        for l in range((F-n*100*A-m*100*B)//C+1):
            for k in range((F-n*100*A-m*100*B-l*C)//D+1):
#                 print("n,m,l,k={},{},{},{}".format(n,m,l,k))
                if n**2+m**2>0 and l*C+k*D<=E*(n*A+m*B):
#                     print("d={}".format((l*C+k*D)/(n*100*A+m*100*B+l*C+k*D)))
                    if cmax<(l*C+k*D)/(n*100*A+m*100*B+l*C+k*D):
                        cmax = (l*C+k*D)/(n*100*A+m*100*B+l*C+k*D)
                        x = n*100*A+m*100*B
                        y = l*C+k*D
                    
print(x+y,y)

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int,input().split( ))
mx = 0
ans = [0,0]
for i in range(f//(a*100)+1):
    sup_b = f-i*a*100
    
    for j in range(sup_b//(b*100)+1):
        wat = i*a*100 + j*b*100
        
        if wat > f or not wat:
            continue
        sup_sug = min(e*(wat/100), f - wat)

        
        for k in range(int(sup_sug//c)+1):
            l = (sup_sug - k*c)//d
            
            if (k*c + l*d)/wat > e/100:
                continue
                
            if mx < (k*c + l*d)/wat:
                mx = (k*c + l*d)/wat
                ans = [(k*c + l*d) + wat, k*c + l*d]
if int(ans[0])==0 and int(ans[1])==0:
    print(100*a,0)
else:
    print(int(ans[0]),int(ans[1]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    A, B, C, D, E, F = map(int, input().split())
    waters = set()
    sugars = set()
    for a in range(0, F+1, 100 * A):
        for b in range(0, F+1, 100 * B):
            if a + b <= F:
                waters.add(a + b)
            else:
                break
    for c in range(0, F+1, C):
        for d in range(0, F+1, D):
            if c + d <= F:
                sugars.add(c + d)
            else:
                break
    waters = sorted(list(waters))[1:]
    sugars = sorted(list(sugars))
    # print(sugars)
    ans = 0
    ans_w = 0
    ans_s = 0
    for w in waters:
        for s in sugars:
            if w + s <= F:
                if s <= (w//100) * E:
                    tmp = (100 * s)/(w + s)
                    # if w == 1700:
                        # print(w, s, (100 * s)/(w + s))
                    if tmp >= ans:
                        ans = tmp
                        ans_w = w
                        ans_s = s
            else:
                break
    print(ans_w + ans_s, ans_s)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def solve():
    A, B, C, D, E, F = map(int, input().split())
    A, B = 100 * A, 100 * B
    waters = set()
    sugars = set()
    for i in range(3001):
        for j in range(3001):
            if A * i + B * j <= F:
                waters.add(A * i + B * j)
            if C * i + D * j <= F:
                sugars.add(C * i + D * j)
    ans_per = 0
    ans_water = 0
    ans_sugar = 0
    for w in waters:
        if w == 0:
            continue
        for s in sugars:
            if w + s <= F and ans_per <= s / w <= E / 100:
                ans_per = s / w
                ans_water = w
                ans_sugar = s
    print(ans_water + ans_sugar, ans_sugar)


if __name__ == '__main__':
    import datetime
    # print(datetime.datetime.now())
    solve()
    # print(datetime.datetime.now())

Submission status: Accepted

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

total = 0
sugar = 0
max_concentration = 0

for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        for k in range(f//c+1):
            for l in range(f//d+1):
                if 0 < 100*(a*i+b*j)+(c*k+d*l)<=f and c*k+d*l<=e*(a*i+b*j):
                    if max_concentration <= (c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l)):
                        max_concentration = (c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l))
                        total = 100*(a*i+b*j)+(c*k+d*l)
                        sugar = (c*k+d*l)
print(total,sugar)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
A *= 100
B *= 100
check = -1
for i in range(F//A+1):
    for j in range((F-(A*i))//B+1):
        if i == 0 and j == 0:continue
        for k in range((F-(A*i)-(B*j))//C+1):
            for l in range((F-(A*i)-(B*j)-(C*k))//D+1):
                water = A*i+B*j
                sugar = C*k+D*l
                if sugar > water//100*E:continue
                if check < sugar / (water+sugar):
                    check = sugar / (water+sugar)
                    ans = [water+sugar,sugar]
print(*ans)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
A *= 100
B *= 100
check = -1
for i in range(F//A+1):
    for j in range((F-(A*i))//B+1):
        if i + j == 0:continue
        for k in range(((F-(A*i))-B*j)//C+1):
            for l in range((((F-(A*i))-B*j)-C*k)//D+1):
                water = A*i+B*j
                sugar = C*k+D*l
                if water//100*E < sugar:continue
                if check < 100*sugar/(water+sugar):
                    check = 100*sugar/(water+sugar)
                    ans = [water+sugar,sugar]
print(*ans)

Submission status: Accepted

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

def dence(a,b,c,d):
  return a*A+b*B+c*C+d*D


for a in range(F//A+1):
  for b in range(F-a*100//B+1):
    for c in range((F-a*A-b*B)//C+1):
      for d in range((F-a*A-b*B-c*C)//D+1):
        if (a*A+b*B)*E/100 >= c*C+d*D and any(i for i in [a,b,c,d]):
          
          if 100*(c*C+d*D)/(a*A+b*B+c*C+d*D) > den:
            #print(a,b,c,d)
            den = 100*(c*C+d*D)/(a*A+b*B+c*C+d*D)
            #print(den)
            ans = [a*A+b*B+c*C+d*D, c*C+d*D]
if ans[1]:
  print(ans[0], ans[1])
else:
  print(A, 0)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in reversed(range(max_sugar // C + 1)):
        for k in reversed(range((max_sugar - j * C) // D + 1)):
            sugar = max(sugar, j * C + k * D)
            if max_sugar == sugar:
                break
        else:
            continue
        break
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

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

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in reversed(range(max_sugar // C + 1)):
        for k in range((max_sugar - j * C) // D + 1):
            sugar = max(sugar, j * C + k * D)
            if max_sugar == sugar:
                break
        else:
            continue
        break
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

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

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in range(max_sugar // C + 1):
        for k in range((max_sugar - j * C) // D + 1):
            sugar = max(sugar, j * C + k * D)
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

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

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = [0]
    for j in range(max_sugar // C + 1):
        for k in range((max_sugar - j * C) // D + 1):
            sugar.append(j * C + k * D)
    max_sugar = max(sugar)
    concentration = max_sugar / (i + max_sugar)
    if c < concentration:
        c = concentration
        ans = [i + max_sugar, max_sugar]

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

Submission status: Accepted

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

for i in range(1, F // (100 * A) + 1):
    for j in range((F - 100 * A * i) // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        for k in range((F - a) // C + 1):
            for l in range((F - a - C * k) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

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

Submission status: Accepted

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

for i in range(1, F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b and a + b <= F:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

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

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
c = []
ans_list = []

for i in range(1, F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a) // D + 1):
                b = k * C + l * D
                if (A * i + B * j) * E >= b and a + b <= F:
                    c.append(100 * b / (a + b))
                    ans_list.append([a + b, b])
                else:
                    break

ans = ans_list[c.index(max(c))]

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

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
checklist=[]
for num1 in range(f//(100*a)+1):
    for num2 in range((f//100*b)+1):
        #(0からfまでの値を num1とnum2に代入して調べる)
        if (100*a)*(num1)+(100*b)*(num2)<=f and [num1,num2]!=[0,0] and (100*num1)*a+(100*num2)*b not in checklist:
            checklist.append((100*num1)*a+(100*num2)*b)
sugarlist=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)           
sugarlist .append(0)
maxsugar=0
ratio=-1
good=0           
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*x<=e*y:
            if x/y>=ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
V = 0
ans = ()
for i in range(F//(A*100)+1):
  for j in range(F//(B*100)+1):
    m = A*i + B*j
    m = m*100
    if m>F or m==0:
      continue
    lim = min(m*E//100, F-m)
    
    l = lim
    w = 0
    z = 0
    for x in range(lim//C+1):
      for y in range(lim//D+1):
        n = x*C+y*D
        if n>lim:
          continue
        if lim-n<l:
          l = lim-n
          w = x
          z = y
    s = w*C+z*D
    v = 100*s/(m+s)
    if v>=V:
      ans = (m+s,s)
      V = v
print(*ans)

Submission status: Accepted

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

waters = []
sugars = []

for w in range(f // 100):
    for i in range(0, w+1, a):
        if (w - i) % b == 0:
            waters.append(w)
            break
for s in range(f):
    for i in range(0, s+1, c):
        if (s - i) % d == 0:
            sugars.append(s)
            break

answ = a
anss = 0

for w in waters:
    for s in sugars:
        if 100 * w + s > f:
            continue
        if s > e * w:
            continue
        if w == 0:
            continue
        if s / w > anss / answ:
            answ = w
            anss = s
print(answ*100+anss, anss)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans_sw = 1
ans_s = 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 or 100*A*a+100*B*b == 0:
      continue
    for c in range((A*a+B*b)*E+1):
      for d in range((A*a+B*b)*E+1):
        sw = 100*A*a+100*B*b+C*c+D*d
        s = C*c+D*d
        if 0 < sw <= F and s <= (A*a+B*b)*E and ans_s/ans_sw < s/sw:
          ans_s = s
          ans_sw = sw
if ans_sw == 1:
  print(100*A ,0)
else:
  print(ans_sw, ans_s)

Submission status: Accepted

Solution code:
from collections import defaultdict
A, B, C, D, E, F = [int(x) for x in input().split()]
A *= 100
B *= 100
d = defaultdict(lambda: False)
d2 = defaultdict(lambda: False)
dd2 = defaultdict(lambda: False)

ret = [0, min(A, B), 0]

def dp2(w, s):
  global ret
  total_weight = w + s
  if dd2[(w, s)] != False:
    return d2[(w, s)]
  else:
    dd2[(w, s)] = True
  if (s / w) > E / 100:
    d2[(w, s)] = 0
    return 0
  else:
    d2[(w, s)] = 100 * s / (s + w)
    if d2[(w, s)] > ret[0]:
      ret = [d2[(w, s)], w + s, s]
  if total_weight + C <= F:
    dp2(w, s + C)
  if total_weight + D <= F:
    dp2(w, s + D)
  
def dp(w):
  if d[w]:
    return 0
  dp2(w, 0)
  d[w] = True
  if w + A <= F:
    dp(w + A)
  if w + B <= F:
    dp(w + B)
  return 0

dp(min(A, B))
print(ret[1],ret[2])

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split(' '))
maxconc = 0.0
maxwater = 100*A
maxsugar = 0

for i in range(F//(100*A)+1):
  for j in range((F-100*A*i)//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print('{0} {1}'.format(maxwater+maxsugar,maxsugar))

Submission status: Accepted

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

max_sugar = 0
max_water = 100*A
max_conc = 0.0
A_limit = F // (100*A)
for i in range(A_limit + 1):
    B_limit = (F-100*A*i) // (100*B)
    for j in range(B_limit + 1):
        if i == 0 and j == 0:
            continue
        sugar_limit = min(E * (A*i+B*j), F-100*(A*i+B*j))

        sugar_ = 0
        for c in range(sugar_limit//C + 1):
            d = (sugar_limit-c*C)//D
            temp_sugar = c*C + d*D
            sugar_ = max(sugar_, temp_sugar)
        temp_conc = sugar_/(sugar_+100*(A*i+B*j))
        if temp_conc > max_conc:
            max_conc = temp_conc
            max_water = 100*(A*i + B*j)
            max_sugar = sugar_
print('{0} {1}'.format(max_water+max_sugar, max_sugar))

Submission status: Accepted

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

maxs = 0
maxw = 1
for i in range(0,F//100+1,B):
  for j in range(0,F//100-i+1,A):
    if i+j == 0:
      continue
    w = (i+j)*100
    for k in range(0,min(F-w,E*w//100)+1,D):
      l = min((F-w-k)//C * C,(E*w//100-k)//C * C)
      s = k+l
      #print(i,j,k,l,s/(s+w))
      if maxs/(maxs+maxw) <= s/(s+w):
        maxs = s
        maxw = w
print(maxs+maxw,maxs)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
water,k,l = set(),1,1

while k * A * 100 <= F:
    water.add(k * A * 100)
    k += 1
while l * B * 100 <= F:
    water.add(l * B * 100)
    l += 1
for i in range(1,k):
    for j in range(1,l):
        if (i * A + j * B) * 100 <= F:
            water.add((i * A + j * B) * 100)
        else:
            break

water = list(water)
sugar = []
concentration = []
for i in range(len(water)):
    sugar_limit = min(water[i] // 100 * E, F - water[i])
    temp,k = 0,0
    while k * C <= sugar_limit:
        l = (sugar_limit - k * C) // D
        while l >= 0:
            if k * C + l * D > temp:
                temp = k * C + l * D
            l -= 1
        k += 1
    sugar.append(temp)
    concentration.append(sugar[i] / (water[i] + sugar[i]))

i = concentration.index(max(concentration))
print(water[i] + sugar[i],sugar[i])

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
water, k, l = set(), 1, 1
while k * A * 100 <= F:
    water.add(k * A * 100)
    k += 1
while l * B * 100 <= F:
    water.add(l * B * 100)
    l += 1
for i in range(1, k):
    for j in range(1, l):
        if (i * A + j * B) * 100 <= F:
            water.add((i * A + j * B) * 100)
        else:
            break

water = list(water)
suger = []
concentration = []
for i in range(len(water)):
    suger_limit = min(water[i] // 100 * E, F - water[i])
    temp, k = 0, 0
    while k * C <= suger_limit:
        l = (suger_limit - k * C) // D
        while l >= 0:
            if k * C + l * D > temp:
                temp =  k * C + l * D 
            l -= 1
        k += 1
    suger.append(temp)
    concentration.append(suger[i] / (water[i] + suger[i]))

i = concentration.index(max(concentration))
print(water[i] + suger[i], suger[i])

Submission status: Accepted

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

lst = []

for a in range(0, F, 100*A):
    for b in range(0, F, 100*B):
        x = a + b
        if x == 0 or x > F:
            continue
            
        for c in range(0, F, C):
            for d in range(0, F, D):
                y = c + d
                if x + y > F or 100*y/(x+y) > 100*E/(100+E):
                    break
                lst.append((100*y/(x+y), x+y, y))
                
print(max(lst)[1], max(lst)[2])