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:
#ABC074C
A, B, C, D, E, F=map(int, input().split())
A=100*A
B=100*B
count_A=F//A
count_B=F//B
count_C=F//C
count_D=F//D
max=-1
ans=[0]*2
total=0
density=0
for i in range(count_A+1):
    for j in range(count_B+1):
        if i*A+j*B<=F and 0<i*A+j*B:
            for k in range(count_C+1):
                if i*A+j*B+k*C<=F:
                    for l in range(count_D+1):
                        total=i*A+j*B+k*C+l*D
                        if total!=0:
                            density=(k*C+l*D)/total
                            if total<=F and density<=E/(100+E) and max<density:
                                max=density
                                ans[0]=total
                                ans[1]=k*C+l*D
                                if density==E/(100+E):
                                    print(' '.join(map(str, ans)))
                                    exit()
print(' '.join(map(str, ans)))

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
rec = (0, 0)
ma = 0
for i in range(31):
    for j in range(31):
        for k in range(100):
            t = i * a * 100 + j * b * 100 + c * k
            if t > f:
                break
            for l in range(100):
                s = i * a * 100 + j * b * 100 + c * k + d * l
                if s > f:
                    break
                if c * k + d * l > (a * i + b * j) * e:
                    break
                if (i * a + j * b + c * k + d * l) == 0:
                    continue
                q = (c * k + d * l) / (100 * i * a + 100 * j * b + c * k + d * l) * 100
                if q >= ma:
                    ma = q
                    rec = (s, c * k + d * l)

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

Submission status: Accepted

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

max_water = 0
max_sugar = 0
max_con = 0
max_AB = 31
max_CD = 101

for a in range(max_AB):
    for b in range(max_AB):
        water = (100 * A) * a + (100 * B) * b
        if water == 0:
            break

        for c in range(max_CD):
            for d in range(max_CD):
                sugar = C * c + D * d
                if water + sugar > F:
                    break

                con = 100*sugar / (water + sugar)
                if water/100 * E >= sugar and con >= max_con:
                    max_con = con
                    max_water = water
                    max_sugar = sugar
print(str(max_water+max_sugar) + " " + str(max_sugar))

Submission status: Accepted

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

water = {}
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        wtr = 100*a*i+100*b*j
        if wtr <= f and not wtr in water.keys():
            water[wtr] = 1
water = sorted(water.keys())[1:]

suger = {}
for i in range(f//c+1):
    for j in range(f//d+1):
        sgr = c*i+d*j
        if sgr <= f and not sgr in suger.keys():
            suger[sgr] = 1
suger = sorted(suger.keys())
# print(water, suger)

ans_w = 0
ans_s = 0
concent = 0
for wtr in water:
    for sgr in suger:
        if wtr+sgr > f:
            break
        if sgr > (wtr//100)*e:
            break
        if sgr/(sgr+wtr) >= concent:
            concent = sgr/(sgr+wtr)
            ans_w = wtr+sgr
            ans_s = sgr

print(ans_w, ans_s)

Submission status: Accepted

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

best = -1.0
ws = sg = 0

for a in range(0, F + 1, 100 * A):
    for b in range(0, F - a + 1, 100 * B):
        w = a + b
        m = min(F - w, w * E // 100)

        if w == 0: continue
        for c in range(0, m + 1, C):
            for d in range(0, m - c + 1, D):
                s = c + d
                if best < s / (w + s):
                    best = s / (w + s)
                    ws = w + s
                    sg = s
print(ws, sg)

Submission status: Accepted

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

best = -1.0
a = ws = sg = 0

while 100 * a * A <= F:
    b = 0
    while True:
        w = 100 * (a * A + b * B)
        if w > F: break
        c = 0
        while w + c * C <= F and 100 * c * C <= w * E:
            d = 0
            while True:
                s = c * C + d * D
                if w + s > F or 100 * s > w * E:
                    break
                elif w + s != 0 and best < s / (w + s):
                    best = s / (w + s)
                    ws = w + s
                    sg = s
                d += 1
            c += 1
        b += 1
    a += 1
print(ws, sg)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    ws, ss = set(), set()
    for a in range(F // A + 1):
        for b in range(F // B + 1):
            w = 100 * (a * A + b * B)
            if w != 0 and w <= F:
                ws.add(w)
    for c in range(F + 1):
        for d in range(F + 1):
            if c * C + d * D <= F:
                ss.add(c * C + d * D)

    best = 0
    ans = (0, 0)
    for w in ws:
        for s in ss:
            if w + s > F or s > w * E // 100:
                continue
            if best <= ((100 * s) / (w + s)):
                best = (100 * s) / (w + s)
                ans = (w + s, s)

    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    best = 0
    ans = (0, 0)
    for a in range(F // (100 * A) + 1):
        for b in range(F // (100 * B) + 1):
            if a == 0 and b == 0:
                continue
            for c in range(F // C + 1):
                w = 100 * (a * A + b * B)
                d = min((F - w - c * C), E * w // 100 - c * C) // D
                if d < 0:
                    continue
                s = c * C + d * D
                if best <= ((100 * s) / (w + s)):
                    best = (100 * s) / (w + s)
                    ans = (w + s, s)

    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from operator import itemgetter

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


def f(x, y):
    max_i = F // x
    max_j = F // y
    arr = []
    for i in range(max_i + 1):
        for j in range(max_j + 1):
            a = x * i + y * j
            if a <= F:
                arr.append(a)
    return list(set(arr))


water = f(100 * A, 100 * B)
sugar = f(C, D)

ans = []
for w in water:
    if w == 0:
        continue
    for s in sugar:
        if w + s <= F and s / w <= E / 100:
            ans.append((w + s, s, s / (w + s)))
ans = sorted(ans, key=itemgetter(2), reverse=True)
print(ans[0][0], ans[0][1])

Submission status: Accepted

Solution code:
A, B, C, D, E, F=map(int, input().split())
a=[[str(100*A),'0']]
for i in range(101):
    for j in range(101):
        for k in range(101):
            for l in range(101):
                x=100*A*i+100*B*j
                y=C*k+D*l
                if x+y>F or x==0:
                    break
                if 100*y/(x+y)<=(E*100)/(100+E):
                    a.append([str(x+y),str(y)])
print(' '.join(sorted(a, key=lambda x: (100*int(x[1]))/int(x[0]) if int(x[0])!=0 else 0)[-1]))

Submission status: Accepted

Solution code:
from math import ceil
A,B,C,D,E,F = map(int,input().split())
am,bm,cm,dm=ceil(31/A),ceil(31/B),ceil(F*E/(100+E)/C)+1,ceil(F*E/(100+E)/D)+1
temp = []
for a in range(am):
    for b in range(bm):
        for c in range(cm):
            for d in range(dm):
                w = 100*a*A+100*b*B
                s = c*C+d*D
                if w + s > F:
                    break
                else:
                    if w / 100 * E >= s:
                        temp.append([w+s,s])
print(*sorted(temp, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

Submission status: Accepted

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

water = A*100
salt = 0
conc = 0

# water 1..29 * 100 all
for i in range(1,30):
  Amax = i // A
  notMakeFlag = True
  for k in range(Amax + 1):
    if (i - A * k) % B == 0:
      notMakeFlag = False
      break
  if notMakeFlag:
    continue
  
  #print(i)
  # maximize salt within F and E
  
  Cmax = min(E*i, (F-i*100))//C
  saltmax = 0
  for k in range(Cmax + 1):
    Dcount = (min(E*i, (F-i*100)) - k * C) // D
    saltmax = max(saltmax, k*C + Dcount * D)
  
    if conc < saltmax / (saltmax + i * 100):
      water = i * 100
      salt = saltmax
      conc = saltmax / (saltmax + i * 100)

print(water+salt, salt)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
water=[]
suguar=[]
temp_3=0#砂糖水の量
temp_2=0#s砂糖の量を記録
ans=0#濃度を計算
temp=0
for i in range((f+1)//100):
    for j in range((f+1)//100):
        x=100*i*a+100*j*b
        if 1<=x<=f:
            water.append(x)
for i in range(f+1):
    for j in range(f+1):
        y=c*i+d*j
        if y<=f:
            suguar.append(y)
for i in water:
    for j in suguar:
        total=i+j
        if total<=f:
            if j<=i//100*e:
                ans=100*j/(i+j)
                if temp<=ans:
                    temp=ans
                    temp_2=total
                    temp_3=j
print(temp_2,temp_3)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
noudo_max = (100*E)/(100+E)

# noudo,water,sugar
res = [-float('inf')]*3

i,j = 0,0
while 100*A*i<=F:
    j = 0
    while 100*A*i+100*B*j<=F:
        water = 100*A*i + 100*B*j
        sugar_max = F - water
        # sugarを全探索
        p = 0
        while C*p<=sugar_max:
            q = 0
            while C*p+D*q<=sugar_max:
                sugar = C*p+D*q
                if water+sugar!=0:
                    noudo = (100*sugar)/(water+sugar)
                    if noudo<=noudo_max and res[0]<noudo:
                        res = noudo,water,sugar
                q += 1
            p += 1
        j += 1
    i += 1

print(res[1]+res[2],res[2])

Submission status: Accepted

Solution code:
l = list(map(int,input().split()))	
a = l[0]
b = l[1]
c = l[2]
d = l[3]
e = l[4]
f = l[5]
ass=0
ans = [100*a,0]
for i in range((f//(100*b))+1):
    for j in range((f-100*b*i)//(100*a)+1):
        hj = f-100*b*i-100*a*j
        for k in range((hj//d+1)):
            if f-hj!=0:
                w = 100*k*d/(f-hj)
                if w <= e:
                    r = min((e*(f-hj)/100-d*k)//c,(hj-d*k)//c)
                    if ass <=(d*k+c*r)*100/(f-hj+d*k+c*r):
                        ans[0] = f-hj+d*k+c*r
                        ans[1] = d*k + c*r
                        ass = (d*k+c*r)*100/(f-hj+d*k+c*r)
print(str(int(ans[0]))+' '+str(int(ans[1])))
#print(ass)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans=-1
sugarwater=0
sugar=0
for i in range(101):
    for j in range(101):
        for k in range(101):
            for l in range(101):
                if (c*k+d*l) > e*(a*i+b*j):
                    break
                if (100 * a * i + 100 * b * j == 0 or 100 * a * i + 100 * b * j + c * k + d * l > f):
                    break
                if ans < 100*(c*k+d*l)/(100 * a * i + 100 * b * j + c*k + d*l):
                    ans=100*(c*k+d*l)/(100 * a * i + 100 * b * j + c*k + d*l)
                    sugarwater = 100 * a * i + 100 * b * j + c*k + d*l
                    sugar = c*k+d*l
print("{} {}".format(sugarwater,sugar))

Submission status: Accepted

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

ab_list = set()

for i in range(0,f//100+1,a):
    for j in range(0, f//100-i+1, b):
        ab_list.add(100*(i+j))

ab_max = max(ab_list)

sug_max = int(ab_max*(e/100))

cd_list = set()

for i in range(0,sug_max+1, c):
    for j in range(0, sug_max-i+1, d):
        cd_list.add(i+j)

water = list(ab_list)
water.sort()

sugar = list(cd_list)
sugar.sort()

max_noudo = -1
ans = [0,-1]
for w in water:
    for s in sugar:
        if w==0 and s==0:
            continue
        if 100*s <= e*w and w+s <= f:
            noudo = s/(w+s)
            if noudo > max_noudo:
                max_noudo = noudo
                ans = [w+s, s]
                
print(*ans)

Submission status: Accepted

Solution code:
import itertools
a,b,c,d,e,f = [int(_) for _ in input().split()]

water = []
i = 0
while True:
    j = 0
    if i * 100 * a + j * 100 * b > f:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * 100 * a + j * 100 * b > f:
            break
        water.append(i * 100 * a + j * 100 * b)
        j += 1
    i += 1
set_water = sorted(set(water))

sugar = []
i = 0
while True:
    j = 0
    if i * c + j * d > f * e // 100:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * c + j * d > f * e // 100:
            break
        sugar.append(i * c + j * d)
        j += 1
    i += 1
set_sugar = sorted(set(sugar))

most_dense = 0
final_total = 0
final_sugar = 0
for i, j in itertools.product(range(0,len(set_water)), range(0, len(set_sugar))):
    density = set_sugar[j] / (set_water[i] + set_sugar[j])
    if density > most_dense and set_water[i] * e // 100 >= set_sugar[j] and set_water[i] + set_sugar[j] <= f:
        most_dense = density
        final_total = set_water[i]+set_sugar[j]
        final_sugar = set_sugar[j]

if final_total == 0:
    final_total = a * 100
print(final_total, final_sugar)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

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

    ans_list = []

    for i in range(50):
        for j in range(50):
            for k in range(50):
                for l in range(50):
                    water = 100 * a * i + 100 * b * j
                    sugar = c * k + d * l
                    if water + sugar <= f and water > 0:
                        consentration = (100 * sugar) / (water + sugar)
                        if consentration <= (100 * e) / (100 + e):
                            ans_list.append([consentration, water, sugar])
    ans_list.sort(key=lambda x:x[0])
    print(ans_list[-1][1] + ans_list[-1][2], ans_list[-1][2])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map( int, input().split())
ans = 0
ansL = 0
ansM = 0
for i in range(30//a+1):
    for j in range((30-i)//b+1):
        L = a*i + b*j
        M = 0
        for k in range(f):
            if 100*L + k*c <= f and k*c <= L*e:
                m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d)
                M = max(M, m+k*c)
        if M+L != 0 and 100*L + M <= f and M <= L*e:
            if (M*100)/(M+L*100) > ans:
                ans = (M*100)/(M+L*100)
                ansL = L*100
                ansM = M
if ansL == 0:
    print('{} {}'.format(a*100,0))
else:
    print('{} {}'.format(ansL+ansM,ansM))

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int, input().split())
 
import functools
import sys
sys.setrecursionlimit(10**5)
 
@functools.lru_cache(maxsize=None)
def calc_strength(sugar, water):
    if water == 0: return -1
    return sugar * 100 / (sugar + water)
 
@functools.lru_cache(maxsize=None)
def f(strength, sugar, water):
    cand = [(strength, sugar + water, sugar)]
    for x in ((C, 0), (D, 0), (0, 100*A), (0, 100*B)):
        s, w = sugar + x[0], water + x[1]
        if s + w <= F and s * 100 <= w * E:
            cand.extend([f(calc_strength(s, w), s, w)])
    return max(cand)

e=f(-1, 0, 0)
print(*f(-1, 0, 0)[1:])

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
w = []
for i in range(f // 100 + 2):
    for j in range(f // 100 + 2):
          t = 100 * (a * i + b * j)
          if 0 < t <= f:
              w.append(t)
s = []
for i in range(f // c + 2):
    for j in range(f // d + 2):
          t = c * i + d * j
          if t <= f:
              s.append(t)

ans_ws = -1
ans_s = -1
buf = -1

sat = (e * 100) / (100 + e)
for water in w:
    for sugar in s:
          ttl = (water + sugar)
          if ttl > f:
              continue
          concentration = (sugar * 100) / ttl
          if concentration <= sat:
              if buf < concentration:
                  buf = concentration
                  ans_ws = ttl
                  ans_s = sugar
print(ans_ws, ans_s)

Submission status: Accepted

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

import functools
import sys
sys.setrecursionlimit(10**5)

@functools.lru_cache(maxsize=None)
def calc_strength(sugar, water):
    if water == 0: return -1
    return sugar * 100 / (sugar + water)

@functools.lru_cache(maxsize=None)
def f(strength, sugar, water):
    cand = [(strength, sugar + water, sugar)]
    for x in ((C, 0), (D, 0), (0, 100*A), (0, 100*B)):
        s, w = sugar + x[0], water + x[1]
        if s + w <= F and s * 100 <= w * E:
            cand.append(f(calc_strength(s, w), s, w))
    return max(cand)
    
print(*f(-1, 0, 0)[1:])

Submission status: Accepted

Solution code:
from operator import itemgetter

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


def f(x, y):
    max_i = F // x
    max_j = F // y
    arr = []
    for i in range(max_i + 1):
        for j in range(max_j + 1):
            a = x * i + y * j
            if a <= F:
                arr.append(a)
    return list(set(arr))


water = f(100 * A, 100 * B)
sugar = f(C, D)

ans = []
for w in water:
    if w == 0:
        continue
    for s in sugar:
        if w + s <= F and s / w <= E / 100:
            ans.append((w + s, s, s / (w + s)))
ans = sorted(ans, key=itemgetter(2), reverse=True)
print(ans[0][0], ans[0][1])

Submission status: Accepted

Solution code:
a,b,c,d,e,f = input().split()
A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
F = int(f)

dictmax = {} 
for i in range(31):
	for j in range(31):
		for p in range(101):
			for q in range(101):
				ans_list = []
				if((100*(A*j+B*i))==0):
					break
				elif((100*(A*j+B*i)+(C*q+D*p))>F):
					break

				else:
					if((C*q+D*p) <=E*(A*j+B*i)):
						nodo = (C*q+D*p)/(100*(A*j+B*i)+(C*q+D*p))
						max_ans = 100*(A*j+B*i)+(C*q+D*p)
						sugar = C*q+D*p
	
						dictmax[nodo] = (max_ans,sugar)

max_nodo = max(dictmax.keys())
souryou = dictmax[max_nodo][0]
satou = dictmax[max_nodo][1]
print(souryou,satou)

Submission status: Accepted

Solution code:
def solve():
    
    A, B, C, D, E, F = map(int, input().split())
    memo = {}
    
    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    w = (100*A)*a + (100*B)*b
                    s = C*c + D*d
                    if w ==0:
                        break
                    if w+s > F:
                        break
                    else:
                        if w/100 * E >= s:
                            dist = 100*s/(w+s)
                            memo[a,b,c,d] = dist
    
    max_v = max(memo.values())
    
    for k, v in memo.items():
        if v == max_v:
            print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
            break
 
if __name__ == '__main__':
	solve()

Submission status: Accepted

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

maximum = 0
max_water = 0
max_sugar = 0

queue = [[a, 0], [b, 0]]

visited = set()

while queue:
    now = queue.pop(0)
    now = tuple(now)

    if now in visited:
        continue

    visited.add(now)

    water, sugar = now

    if water * 100 + sugar > f:
        continue

    if (sugar / water) <= e:
        if maximum < sugar / (water*100):
            maximum = sugar / (water * 100)
            max_water = water
            max_sugar = sugar
    queue.append([water+a, sugar])
    queue.append([water+b, sugar])
    queue.append([water, sugar+c])
    queue.append([water, sugar+d])

if max_water == 0:
    print(min(a, b)*100, 0)
else:
    print(max_water*100 + max_sugar, max_sugar)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

water = []
for i in range(0, F+1, A*100):
    for j in range(0, F+1, B*100):
        if i + j <= F:
            water.append(i + j)
water = sorted(list(set(water)), reverse=True)
# 0はあとで割る時に困るので外す
water.pop(len(water)-1)

suger = []
for i in range(0, F+1, C):
    for j in range(0, F+1, D):
        if i + j <= F:
            suger.append(i + j)
suger = sorted(list(set(suger)))

# 合計の初期値に水を入れておく(これは0でもいい気がするんだけど…)
ans_ws = water[0]
ans_s = 0
node = 0
# 水は多い方、砂糖は少ない方から見ていく
for i in range(len(water)):
    for j in range(len(suger)):
        # 合計量チェック
        if water[i] + suger[j] > F:
            break
        # 溶ける量チェック
        if suger[j] / (water[i] + suger[j]) <= E / (E + 100):
            # 最大濃度更新なら答えを更新
            if suger[j] / (water[i] + suger[j]) > node:
                node = suger[j] / (water[i] + suger[j])
                ans_ws = water[i] + suger[j]
                ans_s = suger[j]
print(str(ans_ws) + " " + str(ans_s))

Submission status: Accepted

Solution code:
import bisect

def line_input(f, type):
    return f(map(type, input().split(" ")))

a,b,c,d,e,f = line_input(tuple, int)

max_dens = 0
ans_w = 0
ans_s = 0

wl = set()
for adx in range(0, f // (a*100) + 1):
    for bdx in range(0, f // (b*100) + 1):
        if adx == 0 & bdx == 0:
            continue

        wl.add(a * adx + b * bdx)

sl = set()
for cdx in range(0, f // c + 1):
    for ddx in range(0, f // d + 1):
        sl.add(c * cdx + d * ddx)

for w in wl:
    if w > f:
        continue

    for s in sl:
        cap = f - w * 100
        C = w * 100 + s

        dens = s / C
        if (C <= f) & (s <= e * w) & (max_dens <= dens):
            max_dens = dens
            ans_w = C
            ans_s = s

print(ans_w, ans_s)

Submission status: Accepted

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

A = []
i = 0
while(100*a*i < f):
    A.append(100*a*i)
    i += 1

B = []
i = 0
while(100*b*i < f):
    B.append(100*b*i)
    i += 1

AB = set()
for aa in A:
    for bb in B:
        if aa+bb < f:
            AB.add(aa+bb)
AB.remove(0)

max_sugar = e * f / (100.0 + e)
#print(max_sugar)
C = []
i = 0
while(c*i <= max_sugar):
    C.append(c*i)
    i += 1

D = []
i = 0
while(d*i <= max_sugar):
    D.append(d*i)
    i += 1

CD = set()
for cc in C:
    for dd in D:
        if cc+dd <= max_sugar:
            CD.add(cc+dd)

#print(AB)
#print(CD)

# 全パターン試す
MAX_DENS = e/(e+100.0)
#print(MAX_DENS)
max_dens = -1
max_ws = ()
for water in AB:
    for sugar in CD:
        weight = water + sugar
        dens = sugar / weight
        if weight > f or dens > MAX_DENS:
            continue
        if max_dens < dens:
            #print(dens, MAX_DENS)
            max_dens = dens
            max_ws = (weight, sugar)
#print(max_dens)
print('%d %d' % max_ws)

Submission status: Accepted

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

upper_concentration = E / (100 + E)

def concentration(sugar, water):
    if sugar == 0 and water == 0:
        return False
    c = sugar / (sugar + water)
    if c > upper_concentration:
        return False
    else:
        return c

AB = []
for ia in range(0, int(F / 100 / A) + 1):
    ib = 0
    if ia == 0 and ib == 0:
        continue
    while 100 * (A * ia + B * ib) <= F:
        AB.append([ia, ib])
        ib += 1

c_max = 0
sugar_max = 0
sugar_water_max = 0
water_max = 0

for ia, ib in AB:
    water = 100 * (A * ia + B * ib)
    water_max = max(water_max, water)
    res_water = F - water
    for ic in range(0, int(res_water / C) + 1):
        for id in range(0, int(res_water / D) + 1):
            sugar = C * ic + D * id
            if sugar > res_water:
                break
            c = concentration(sugar, water)
            if not c:
                continue
            if c_max <= c:
                c_max = c
                sugar_max = sugar
                sugar_water_max = sugar + water
if sugar_max == 0:
    print(water_max, 0)
else:
    print(sugar_water_max, sugar_max)

Submission status: Accepted

Solution code:

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

    # 100gあたりE [g]溶ける
    # ビーカーにF [g]いれられる
    # 濃度は100*砂糖 / (水＋砂糖)


    mizu=[]
    sato=[]


    x = int(f/100/a) +1
    y = int(f/100/b) +1

    for i in range(x):
        for j in range(y):
            mizu.append(i*100*a + j*100*b)

    mizu = [i for i in mizu if i <= f]
    mizu = list(set(mizu))
    mizu.sort()

    tokeru = int(f/100) * e
    x = int(tokeru / c) +1
    y = int(tokeru / d) +1

    for i in range(x):
        for j in range(y):
            sato.append(i*c + j*d)

    sato = [i for i in sato if i < tokeru]
    sato = list(set(sato))
    sato.sort()
#    sato.remove(0)
#    mizu.remove(0)

    tmp =0

    for i in mizu:
        for j in sato:
            if i + j <= f and i + j !=0:
                if int(i/100)*e >=j:
                    if tmp <= (100*j) / (i + j):
                        tmp = (100*j) / (i + j)
                        ans = str(i+j) + " " + str(j)

    print(ans)


if __name__ == "__main__":
        main()

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
W = []
for i in range(F // (A * 100) + 1):
  for j in range(F // (B * 100) + 1):
    if (A * i + B * j) and (A * i + B * j) * 100 <= F:
      W.append(A * i + B * j)
c = [0 for w in W]
for k, w in enumerate(W):
  s_upper = min(w * E, F - w * 100)
  s_max = 0
  for i in range(s_upper // C + 1):
    for j in range(s_upper // D + 1):
      if C * i + D * j <= s_upper:
        s_max = max(C * i + D * j, s_max)
  c[k] = [s_max / (s_max + w * 100), s_max, w]
ans = sorted(c, key=lambda x: x[0], reverse=True)[0]
print(ans[1] + ans[2] * 100, ans[1])

Submission status: Accepted

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

waters = set()
for w1 in range(0,F+1,B):
    if w1*100 > F: break
    for w2 in range(0,F+1,A):
        w = (w1+w2)*100
        if w > F: break
        if w==0: continue
        waters.add(w)

sugars = set()
for s1 in range(0,F+1,D):
    if s1 > F: break
    for s2 in range(0,F+1,C):
        s = s1+s2
        if s > F: break
        sugars.add(s)

ans_r = -1
ans_s = ans_w = None
for w in sorted(waters):
    if w > F: break
    for s in sorted(sugars):
        if w+s > F: break
        if s*100 > w*E: break
        r = 100*s/(s+w)
        if r > ans_r:
            ans_r = r
            ans_w = w
            ans_s = s
print(ans_s+ans_w, ans_s)

Submission status: Accepted

Solution code:
A,B,C,D,E,F=map(int,input().split())
#100*A*i + 200*B*j == x
#C*i + D*j == y
xs = []
ys = []
def dens(x,y):
    if x+y==0:
        return(-1)
    else:
        return(y/(x+y))
for i in range(31):
    for j in range(16):
        if 100*A*i + 200*B*j <= F:
            xs.append(100*A*i + 200*B*j)
for i in range(3001):
    for j in range(1501):
        if C*i + D*j <= F:
            ys.append(C*i + D*j)
density = 0
water = 100*A
sugar = 0
for x in xs:
    for y in ys:
        if x+y > F or 100*y > E*x:
            continue
        nd = dens(x,y)
        if nd > density:
            density = nd
            sugar = y
            water = x
print(str(water+sugar) + " " + str(sugar))

Submission status: Accepted

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

t=0

ans1,ans2=100*a,0
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                x = 100*a*i+100*b*j
                y = c*k+d*l
                if x==0:
                    break
                if x/100*e<y:
                    break
                if x+y>f:
                    break
                if y/(x+y)>t:
                    t=y/(x+y)
                    ans1,ans2=x+y,y
print(ans1,ans2)