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: Wrong Answer

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

maxx = 0
answ, anss = 0, 0

for i in range(0, 31):
    for j in range(0, 31):
        water = 100 * a * i + 100 * b * j
        if water == 0:
            continue

        rest = f - water
        if rest < 0:
            break

        ub = water * e // 100
        if ub > rest:
            ub = rest

        for k in range(0, 3001):
            rest2 = ub - c * k
            if rest2 < 0:
                break
            dnum = rest2 // d

            sugar = k * c + dnum * d
            conc = sugar / (water + sugar)
            if maxx < conc:
                maxx = conc
                answ, anss = water+sugar, sugar


assert anss <= f, "error"
print(answ, anss)

Submission status: Wrong Answer

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

maxx = 0
answ, anss = 0, 0

for i in range(0, 31):
    for j in range(0, 31):
        water = 100 * a * i + 100 * b * j
        if water == 0:
            continue
        rest = f - water
        if rest < 0:
            break
        ub = water * e // 100
        if ub > rest:
            ub = rest

        for k in range(0, 3000):
            rest2 = ub - c * k
            if rest2 < 0:
                break
            dnum = rest2 // d

            sugar = k * c + dnum * d
            conc = sugar / (water + sugar)
            if maxx < conc:
                maxx = conc
                answ, anss = water+sugar, sugar


print(answ, anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,raw_input().split())
lim = f
f /= 100
wl = [False for _ in range(f+1)]
sl = [False for _ in range(f*e+1)]
if a <= f:
    wl[a] = True
if b <= f:
    wl[b] = True
if c <= f*e:
    sl[c] = True
if d <= f*e:
    sl[d] = True

for i in range(f):
    if wl[i] and i+a <= f:
        wl[i+a] = True
    if wl[i] and i+b <= f:
        wl[i+b] = True

for i in range(f*e):
    if sl[i] and i+c <= f*e:
        sl[i+c] = True
    if sl[i] and i+d <= f*e:
        sl[i+d] = True

maxd = 0.0
maxw = 0
maxs = 0
for i,w in enumerate(wl):
    for j,s in enumerate(sl):
        if w and s and i*100+j <= lim:
            if i*e >= j and float(j) / float(100*i+j) > maxd:
                maxd = float(j) / float(100*i + j)
                maxw = i*100
                maxs = j

print maxw+maxs,maxs

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f= map(int, input().split())
youeki=0
yousitu=0
noudo=0
n_a=int(f/(100*a))


for i in range(1+n_a):
 for j in range(1+int((f-100*i*a)/(100*b))):
  for k in range(1+int((f-100*i*a-100*j*b)/c)):
   for l in range(1+int((f-100*i*a-100*j*b-k*c)/d)):
    S=100.0*a*i+100.0*b*j+c*k+d*l
    T=c*k+d*l
    if S!=0:
     L=100.0*T/S
     if S<=f and L<=100.0*e/(100.0+e) and L>noudo:
      noudo=L
      youeki=S
      yousitu=T
print(int(youeki),int(yousitu))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f= map(int, input().split())
youeki=0
yousitu=0
noudo=0
n_a=int(f/(100*a))


for i in range(2+n_a):
 for j in range(2+int((f-100*i*a)/(100*b))):
  for k in range(2+int((f-100*i*a-100*j*b)/c)):
   for l in range(2+int((f-100*i*a-100*j*b-k*c)/d)):
    S=100.0*a*i+100.0*b*j+c*k+d*l
    T=c*k+d*l
    if S!=0:
     L=100.0*T/S
     if S<=f and L<=100*e/(100+e) and L>noudo:
      noudo=L
      youeki=S
      yousitu=T
print(int(youeki),int(yousitu))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f= map(int, input().split())
youeki=0
yousitu=0
noudo=0
n_a=int(f/(100*a))


for i in range(1+n_a):
 for j in range(1+int((f-100*i*a)/(100*b))):
  for k in range(1+int((f-100*i*a-100*j*b)/c)):
   for l in range(1+int((f-100*i*a-100*j*b-k*c)/d)):
    S=100.0*a*i+100.0*b*j+c*k+d*l
    T=c*k+d*l
    if S!=0:
     L=100.0*T/S
     if S<=f and L<=100*e/(100+e) and L>noudo:
      noudo=L
      youeki=S
      yousitu=T
print(int(youeki),int(yousitu))

Submission status: Wrong Answer

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

    W = [100*A*x + 100*B*y for x in range(0, 31) for y in range(0, 31) if 0 < (100*A*x + 100*B*y) <= F]
    S = [C*x + D*y for x in range(0, 31) for y in range(0, 31) if 0 < (C*x + D*y) <= F]

    dense, sugar, mass = 0, 0, 100*A
    for w in W:
        for s in S:
            if ((w+s) <= F and s <= (w*E/100) and dense*(s+w) < s):
                dense = s/(s+w)
                sugar = s
                mass = s+w
    print(mass, sugar)

    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    water, sugar = [], []
    for i in range(f+1):
        for j in range(f+1):
            w = 100*a*i + 100*b*j
            s = c*i + d*j
            if w <= f:
                water.append(w)
            if s <= f:
                sugar.append(s)

    max_r = 0
    for w in water:
        for s in sugar:
            sw = s+w
            if sw == s:
                r = 100.
            else:
                r = s/sw
            if sw <= f and r<=e/100 and r >= max_r:
                max_sw = sw
                max_s = s
                max_r = r
    print("{} {}".format(max_sw, max_s))
    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

W = [ 100*A*x + 100*B*y for x in range(0,31) for y in range(0,31) if 0 < (100*A*x + 100*B*y) <= F]
S = [ C*x + D*y for x in range(0,3001) for y in range(0,3001) if 0 < (C*x + D*y) <= F]

dense = 0
sugar = 0
mass = 0
for w in W:
    for s in S:
        if ((w + s) <= F and s <= (w*E/100) and dense*(s+w) < s):
            dense = s/(s+w)
            sugar = s
            mass = s+w
print(mass,sugar)

Submission status: Wrong Answer

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

W = [ 100*A*x + 100*B*y for x in range(0,101) for y in range(0,101) if 0 < (100*A*x + 100*B*y) <= F]
S = [ C*x + D*y for x in range(0,31) for y in range(0,31) if 0 < (C*x + D*y) <= F]

dense = 0
sugar = 0
mass = 0
for w in W:
    for s in S:
        if ((w + s) <= F and s <= (w*E/100) and dense < s/(s+w)):
            dense = s/(s+w)
            sugar = s
            mass = s+w
print(mass,sugar)

Submission status: Wrong Answer

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

W = [ 100*A*x + 100*B*y for x in range(0,31) for y in range(0,31) if 0 < (100*A*x + 100*B*y) <= F]
S = [ C*x + D*y for x in range(0,3001) for y in range(0,3001) if 0 < (C*x + D*y) <= F]

dense = 0
sugar = 0
mass = 0
for w in W:
    for s in S:
        if ((w + s) <= F and s <= (w*E/100) and dense < s/(s+w)):
            dense = s/(s+w)
            sugar = s
            mass = s+w
print(mass,sugar)

Submission status: Wrong Answer

Solution code:
def Sugar_water():
    key_list = ["wA", "wB", "sC", "sD", "dE", "tF"]
    # val = "1 2 1 2 100 1000"
    val = "17 19 22 26 55 2802"
    # val = "1 2 1 2 1 101"
    if 'LOCAL_FLAG' in globals():
        val_list = list(map(int, val.split()))
    else:
        val_list = list(map(int, input().split()))

    var = dict(zip(key_list, val_list))
    limit = var.copy()

    m_density=0
    m_sugar=0
    m_water=0

    limit_density=var['dE']/(100+var['dE'])
    limit['wA'] = int(var['tF']/100/var['wA'])
    limit['wB'] = int(var['tF']/100/var['wB'])

    for A in range(0, limit['wA']+1):
        for B in range(0, limit['wB']+1):
            water = 100*var['wA']*A + 100*var['wB']*B
            if(water > var['tF']):
                break
            elif((var['tF']-water)*m_density > (var['tF']-water)):
                break
            limit['sC'] = int(water/100*var['dE']/var['sC'])
            limit['sD'] = int(water/100*var['dE']/var['sD'])

            for C in range(0, limit['sC']+1):
                for D in range(0, limit['sD']+1):
                    sugar = var['sC']*C + var['sD']*D

                    total = water + sugar
                    density = sugar / total if total > 0 else 0

                    if(total > var['tF']):
                        break
                    elif(density > limit_density):
                        break
                    elif(density > m_density):
                        # print("# ", total, " ", sugar, " ", density, "  -- ", A, B, C, D)
                        m_density=density
                        m_sugar=sugar
                        m_water=water



    print(m_sugar + m_water, " ", m_sugar)

Sugar_water()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

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

w_list = []
for i in range(math.ceil(F / (100 * A)) + 1):
    for j in range(math.ceil(F / (100 * B)) + 1):
        if i == 0 and j == 0:
            continue
        water = 100 * A * i + 100 * B * j
        if water <= F:
            w_list.append(water)

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

max_c = 0
max_w = 0
max_s = 0
for w in set(w_list):
    for s in set(s_list):
        if w + s > F:
            continue
        if s > int(E * w / 100):
            continue
        elif s == int(E * w / 100):
            max_w = w
            max_s = s
            break
        c = 100 * s / (w + s)
        if c > max_c:
            max_c = c
            max_w = w
            max_s = s

print(max_w + max_s, max_s, end = " ")

Submission status: Wrong Answer

Solution code:
arr = [int(ele) for ele in input().split(' ')]
s = []
w = []
s.append(arr[2])
s.append(arr[3])
s.append(arr[2]+arr[3])
w.append(100 * arr[0])
w.append(100 * arr[1])
w.append(100*arr[0] + 100 * arr[1])

maximum = 0
for sugar in s:
    for water in w:
        if sugar + water < arr[5]:
            if 100 * sugar / (sugar + water) <= 100 * arr[4]/ (arr[4] + 100):
                if sugar + water > maximum:
                    print("%d %d" % (sugar + water, sugar))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

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

w_list = []
for i in range(math.ceil(F / (100 * A)) + 1):
    for j in range(math.ceil(F / (100 * B)) + 1):
        if i == 0 and j == 0:
            continue
        water = 100 * A * i + 100 * B * j
        if water <= F:
            w_list.append(water)

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

max_c = 0
max_w = 0
max_s = 0
for w in set(w_list):
    for s in set(s_list):
        if w + s > F:
            continue
        if s > int(E * w / 100):
            continue
        c = 100 * s / (w + s)
        if c > max_c:
            max_c = c
            max_w = w
            max_s = s

print(max_w + max_s, max_s, end = " ")

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

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

w_list = []
for i in range(math.ceil(F / (100 * A)) + 1):
    for j in range(math.ceil(F / (100 * B)) + 1):
        if i == 0 and j == 0:
            continue
        water = 100 * A * i + 100 * B * j
        if water <= F:
            w_list.append(water)

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

max_c = 0.0
max_w = 0
max_s = 0
for w in set(w_list):
    for s in set(s_list):
        if w + s > F:
            continue
        if s > int(E * w / 100):
            continue
        c = 100 * s / (w + s)
        if c > max_c:
            max_c = c
            max_w = w
            max_s = s

print(max_w + max_s, max_s, end = " ")

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

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

w_list = []
for i in range(math.ceil(F / (100 * A)) + 1):
    for j in range(math.ceil(F / (100 * B)) + 1):
        if i == 0 and j == 0:
            continue
        water = 100 * A * i + 100 * B * j
        if water <= F:
            w_list.append(water)

s_list = []
for i in range(math.ceil(F / C) + 1):
    for j in range(math.ceil(F / D) + 1):
        if i == 0 and j == 0:
            continue
        sugar = C * i + D * j
        if sugar <= F:
            s_list.append(sugar)

max_c = 0.0
max_w = 0
max_s = 0
for w in set(w_list):
    for s in set(s_list):
        if w + s > F:
            continue
        if s > int(E * w / 100):
            continue
        c = 100 * s / (w + s)
        if c > max_c:
            max_c = c
            max_w = w
            max_s = s

print(max_w + max_s, max_s, end = " ")

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

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

w_list = []
for i in range(math.ceil(F / (100 * A)) + 1):
    for j in range(math.ceil(F / (100 * B)) + 1):
        if i == 0 and j == 0:
            continue
        water = 100 * A * i + 100 * B * j
        if water <= F:
            w_list.append(water)

s_list = []
for i in range(math.ceil(F / C) + 1):
    for j in range(math.ceil(F / D) + 1):
        if i == 0 and j == 0:
            continue
        sugar = C * i + D * j
        if sugar <= F:
            s_list.append(sugar)

max_c = 0.0
max_w = 0
max_s = 0
for w in set(w_list):
    for s in set(s_list):
        if w + s > F:
            continue
        if s > E * w / 100:
            continue
        c = 100 * s / (w + s)
        if c > max_c:
            max_c = c
            max_w = w
            max_s = s

print(max_w + max_s, max_s, end = " ")

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

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

w_list = []
for i in range(math.ceil(F / (100 * A)) + 1):
    for j in range(math.ceil(F / (100 * B)) + 1):
        if i == 0 and j == 0:
            continue
        water = 100 * A * i + 100 * B * j
        if water <= F:
            w_list.append(water)

s_list = []
for i in range(math.ceil(F / C)):
    for j in range(math.ceil(F / D)):
        if i == 0 and j == 0:
            continue
        sugar = C * i + D * j
        if sugar <= F:
            s_list.append(sugar)

max_c = 0.0
max_w = 0
max_s = 0
for w in set(w_list):
    for s in set(s_list):
        if w + s > F:
            continue
        if s > E * w / 100:
            continue
        c = 100 * s / (w + s)
        if c > max_c:
            max_c = c
            max_w = w
            max_s = s

print(max_w + max_s, max_s, end = " ")

Submission status: Wrong Answer

Solution code:
def node(hen, sin):
    if hen == 0 or sin == 0:
        return 0
    return 100 * sin / (hen + sin)


a, b, c, d, e, f = [int(i) for i in input().split()]
node_ans = 0
water_ans = 0
sugar_ans = 0
for A in range(0, f, a * 100):
    for B in range(0, f, b * 100):
        water = A + B
        max_sugar = water * e
        for C in range(0, f, c):
            for D in range(0, f, d):
                sugar = C + D
                if max_sugar < sugar*100 or f < water + sugar or water == 0:
                    break
                elif node_ans < node(water, sugar):
                    node_ans = node(water, sugar)
                    sugar_ans = sugar
                    water_ans = water

print(water_ans + sugar_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
def node(hen, sin):
    if hen == 0 or sin == 0:
        return 0
    return 100 * sin / (hen + sin)


a, b, c, d, e, f = [int(i) for i in input().split()]
node_ans = 0
water_ans = 0
sugar_ans = 0
for A in range(0, f, a * 100):
    for B in range(0, f, b * 100):
        water = A + B
        max_sugar = water * e // 100
        for C in range(0, f, c):
            for D in range(0, f, d):
                sugar = C + D
                if max_sugar < sugar or f < water + sugar:
                    break
                elif node_ans < node(water, sugar):
                    node_ans = node(water, sugar)
                    sugar_ans = sugar
                    water_ans = water

print(water_ans + sugar_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
def node(a, b):
    if a == 0 or b == 0:
        return 0
    return 100 * b / (a + b)


a, b, c, d, e, f = [int(i) for i in input().split()]
max_sugar = e * f / 100
max_water = f - max_sugar
water_ans = 0
s = 0
water = set()
check = 0
n = 0
while check <= f:
    while check <= f:
        water.add(check)
        check += b * 100
    check = a * 100 * n
    n += 1
check = 0
n = 0
sugar_ans = 0
g = 0
node_ans = 0
for i in water:
    max_sugar = e * i // 100
    for C in range(0, f, c):
        for D in range(0, f, d):
            sugar = C + D
            if node_ans < node(i, sugar) and i + sugar <= f and sugar <= max_sugar:
                node_ans = node(i,sugar)
                sugar_ans = sugar
                water_ans = i
            else:
                break

print(water_ans + sugar_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
def per(a, b):
    if a == 0 or b == 0:
        return 0
    return 100 * b / (a + b)


a, b, c, d, e, f = [int(i) for i in input().split()]
max_sugar = e * f / 100
max_water = f - max_sugar
water_ans = 0
s = 0
water = set()
check = 0
n = 0
while check <= f:
    while check <= f:
        water.add(check)
        check += b * 100
    check = a * 100 * n
    n += 1
check = 0
n = 0
sugar_ans = 0
g = 0
for i in water:
    max_sugar = e * i / 100
    while check <= max_sugar and check + i <= f:
        while check <= max_sugar and check + i <= f:
            if g < per(i, check) and i + check <= f:
                sugar_ans = check
                g = per(i, check)
                water_ans = i
            check += d
        if g < per(i, check) and i + check <= f and check <= max_sugar:
            sugar_ans = check
            g = per(i, check)
            water_ans = i
        check = c * n
        n += 1

print(water_ans + sugar_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
def per(a, b):
    if a == 0 or b == 0:
        return 0
    return 100 * b / (a + b)


a, b, c, d, e, f = [int(i) for i in input().split()]
max_sugar = e * f / 100
max_water = f - max_sugar
water_ans = 0
s = 0
water = set()
check = 0
n = 0
while check <= f:
    while check <= f:
        water.add(check)
        check += b * 100
    check = a * 100 * n
    n += 1
check = 0
n = 0
sugar_ans = 0
g = 0
for i in water:
    max_sugar = e * i / 100
    while check <= max_sugar and check + i <= f:
        while check <= max_sugar and check + i <= f:
            if g < per(i, check) and i + check <= f:
                sugar_ans = check
                g = per(i, check)
                water_ans = i
            check += d
        if g < per(i, check) and i + check <= f:
            sugar_ans = check
            g = per(i, check)
            water_ans = i
        check = c * n
        n += 1

print(water_ans + sugar_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
def per(a, b):
    if a == 0 or b == 0:
        return 0
    return 100 * b / (a + b)


a, b, c, d, e, f = [int(i) for i in input().split()]
max_sugar = e * f / 100
max_water = f - max_sugar
water_ans = 0
s = 0
water = set()
check = 0
n = 0
while check <= f:
    while check <= f:
        water.add(check)
        check += b * 100
    check = a * 100 * n
    n += 1
check = 0
n = 0
sugar_ans = 0
g = 0
for i in water:
    max_sugar = e * i / 100
    while check <= max_sugar and check + i <= f:
        while check <= max_sugar and check + i <= f:
            if g < per(i, check) and i + check <= f:
                sugar_ans = check
                g = per(i, check)
                water_ans = i
            check += d
        if g < per(i, check) and i + check <= f:
            sugar_ans = check
            g = per(i, check)
            water_ans = i
        check = c * n
        n += 1

print(water_ans + sugar_ans, sugar_ans)
print(max_sugar)

Submission status: Wrong Answer

Solution code:
def per(a, b):
    if a == 0 or b == 0:
        return 0
    return 100 * b / (a + b)


a, b, c, d, e, f = [int(i) for i in input().split()]
max_sugar = e * f / 100
max_water = f - max_sugar
water_ans = 0
s = 0
water = set()
check = 0
n = 0
while check <= f:
    while check <= f:
        water.add(check)
        check += b * 100
    check = a * 100 * n
    n += 1
check = 0
n = 0
sugar_ans = 0
g = 0
for i in water:
    max_sugar = e * i / 100
    while check <= max_sugar and check + i <= f:
        while check <= max_sugar and check + i <= f:
            if g < per(i, check) and i + check <= f:
                sugar_ans = check
                g = per(i, check)
                water_ans = i
            check += d
        check = c * n
        n += 1

print(water_ans + sugar_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
#Sugar.py
#1 2 10 20 15 200
a, b, c, d, e, f = (int(_) for _ in raw_input().split()) 

salt = []
water = []

#salt
#print('salt')
di = f/d
ci=0
while di >= 0:
	if (c*ci+d*di) <= f:
		tmp = c*ci+d*di
		salt.append(tmp)
		#print(tmp)
		#print('salt:{0} ci:{1} di:{2}'.format(tmp,ci,di))

		if (c*(ci+1)+d*di) <= f:
			ci += 1
		else:
			di -= 1
			ci = 0
	else:
		di -= 1
		ci = 0
#print(salt)

#print('water')
bi = f/(100*b)
ai=0
while bi >= 0:
	if (100*a*ai+100*b*bi) <= f:
		tmp = 100*a*ai+100*b*bi
		water.append(tmp)

		if (100*a*(ai+1)+100*b*bi) <= f:
			ai += 1
		else:
			bi -= 1
			ai = 0
	else:
		bi -= 1
		ai = 0
#print(water)

salt_ans = 0
water_ans = 0 
ans_conc = 0
dist = 0

for w in water:
#	print(i)
	for s in salt:
		if s+w == 0:
			dist = 1 + e
			#print('water:{0} salt:{1}'.format(w,s))
			#print(dist)
		elif s+w >= f:
			dist = 1 + e
		elif w == 0 :
			dist = 1 + e
		#elif s > w:
		#	dist = 1 + e
		else:
			#dist = (100*s/(s+w))
			dist = (float(100 * s)/ w)

		if dist == e:
				salt_ans = s
				water_ans = w+s
				break
		
		if dist <= e:
			conc_tmp = float(100*s)/(s+w)
			if ans_conc < conc_tmp:
				#print('s:{0} w:{1} dist:{2} e:{3}'.format(s,w,dist,e))
				#print('conc_tmp:{0}'.format(conc_tmp))
				#print('registttttttttttttttttttttttt')
				salt_ans = s
				water_ans = w+s
				ans_conc = conc_tmp
				#print('water:{0} salt:{1}'.format(water_ans,salt_ans))

print('{0} {1}'.format(water_ans,salt_ans))

Submission status: Wrong Answer

Solution code:
x =  list(map(int, input().split()))
max_per = 100*(x[4]) / 100
now_max_per = 0
ansSugarWater = 0
ansSugar = 0
for B in range(int(x[5]/(100*x[1]))):
    for A in range(int((x[5]-100*B*x[1])/(100*x[0]))+ 1):
        now_sugar = 0
        can_sugar = max_per * (x[0]*A + x[1]*B)
        if can_sugar + 100*x[0]*A + 100*x[1]*B > x[5]:
            can_sugar = x[5] - 100*x[0]*A - 100*x[1]*B
        i = [0,0]
        for D in range(int(can_sugar / x[3] + 1)):
            for C in range(int((can_sugar - D*x[3])/x[2])+ 1):
                if C*x[2] + D*x[3] > now_sugar:
                    now_sugar = C*x[2] + D*x[3]
                    i = [C, D]
        C = i[0]
        D = i[1]
        if  A == 0 and B == 0:
            continue
        elif C*x[2] + D*x[3] > can_sugar:
            continue
        elif 100*x[0]*A + 100*x[1]*B + x[2]*C + x[3]*D > x[5]:
            continue
        elif x[0] > 30 or x[1] > 30 or x[2] > 30 or x[3] > 30:
            continue
        else:
            now_per = 100 * (C*x[2] + D*x[3]) / (100*(A*x[0] + B*x[1]) + C*x[2] + D*x[3])
        if max_per >= now_per > now_max_per :
            now_max_per = now_per
            ansSugarWater = 100 * (A*x[0] + B*x[1]) + C*x[2] + D*x[3]
            ansSugar = C*x[2] + D*x[3]
print("{0} {1}".format(ansSugarWater, ansSugar))

Submission status: Wrong Answer

Solution code:
x =  list(map(int, input().split()))
max_per = 100*(x[4]) / 100
now_max_per = 0
ansSugarWater = 0
ansSugar = 0
for B in range(min(int(x[5]/(100*x[1])), 30)):
    for A in range(min(int((x[5]-100*B*x[1])/(100*x[0]))+ 1, 31)):
        now_sugar = 0
        can_sugar = max_per * (x[0]*A + x[1]*B)
        if can_sugar + 100*x[0]*A + 100*x[1]*B > x[5]:
            can_sugar = x[5] - 100*x[0]*A - 100*x[1]*B
        i = [0,0]
        for D in range(min(int(can_sugar / x[3] + 1), 31)):
            for C in range(min(int((can_sugar - D*x[3])/x[2])+ 1, 31)):
                if C*x[2] + D*x[3] > now_sugar:
                    now_sugar = C*x[2] + D*x[3]
                    i = [C, D]
        C = i[0]
        D = i[1]
        if  A == 0 and B == 0:
            continue
        elif C*x[2] + D*x[3] > can_sugar:
            continue
        elif 100*x[0]*A + 100*x[1]*B + x[2]*C + x[3]*D > x[5]:
            continue
        else:
            now_per = 100 * (C*x[2] + D*x[3]) / (100*(A*x[0] + B*x[1]) + C*x[2] + D*x[3])
        if max_per >= now_per > now_max_per :
            now_max_per = now_per
            ansSugarWater = 100 * (A*x[0] + B*x[1]) + C*x[2] + D*x[3]
            ansSugar = C*x[2] + D*x[3]
print("{0} {1}".format(ansSugarWater, ansSugar))

Submission status: Wrong Answer

Solution code:
x =  list(map(int, input().split()))
max_per = 100*(x[4]) / 100
now_max_per = 0
ansSugarWater = 0
ansSugar = 0
for B in range(min(int(x[5]/(100*x[1])), 31)):
    for A in range(min(int((x[5]-100*B*x[1])/(100*x[0]))+ 1, 31)):
        now_sugar = 0
        can_sugar = max_per * (x[0]*A + x[1]*B)
        if can_sugar + 100*x[0]*A + 100*x[1]*B > x[5]:
            can_sugar = x[5] - 100*x[0]*A - 100*x[1]*B
        i = [0,0]
        for D in range(min(int(can_sugar / x[3] + 1), 31)):
            for C in range(min(int((can_sugar - D*x[3])/x[2])+ 1, 31)):
                if C*x[2] + D*x[3] > now_sugar:
                    now_sugar = C*x[2] + D*x[3]
                    i = [C, D]
        C = i[0]
        D = i[1]
        if  A == 0 and B == 0:
            continue
        elif C*x[2] + D*x[3] > can_sugar:
            continue
        elif 100*x[0]*A + 100*x[1]*B + x[2]*C + x[3]*D > x[5]:
            continue
        else:
            now_per = 100 * (C*x[2] + D*x[3]) / (100*(A*x[0] + B*x[1]) + C*x[2] + D*x[3])
        if max_per >= now_per > now_max_per :
            now_max_per = now_per
            ansSugarWater = 100 * (A*x[0] + B*x[1]) + C*x[2] + D*x[3]
            ansSugar = C*x[2] + D*x[3]
print("{0} {1}".format(ansSugarWater, ansSugar))

Submission status: Wrong Answer

Solution code:
x =  list(map(int, input().split()))
max_per = 100*(x[4]) / 100
now_max_per = 0
ansSugarWater = 0
ansSugar = 0
for B in range(int(x[5]/(100*x[1]))):
    for A in range(int((x[5]-100*B*x[1])/(100*x[0]))+ 1):
        now_sugar = 0
        can_sugar = max_per * (x[0]*A + x[1]*B)
        if can_sugar + 100*x[0]*A + 100*x[1]*B > x[5]:
            can_sugar = x[5] - 100*x[0]*A - 100*x[1]*B
        i = [0,0]
        for D in range(int(can_sugar / x[3] + 1)):
            for C in range(int((can_sugar - D*x[3])/x[2])+ 1):
                if C*x[2] + D*x[3] > now_sugar:
                    now_sugar = C*x[2] + D*x[3]
                    i = [C, D]
        C = i[0]
        D = i[1]
        if  A == 0 and B == 0:
            continue
        elif C*x[2] + D*x[3] > can_sugar:
            continue
        elif 100*x[0]*A + 100*x[1]*B + x[2]*C + x[3]*D > x[5]:
            continue
        else:
            now_per = 100 * (C*x[2] + D*x[3]) / (100*(A*x[0] + B*x[1]) + C*x[2] + D*x[3])
        if max_per >= now_per > now_max_per :
            now_max_per = now_per
            ansSugarWater = 100 * (A*x[0] + B*x[1]) + C*x[2] + D*x[3]
            ansSugar = C*x[2] + D*x[3]
print("{0} {1}".format(ansSugarWater, ansSugar))

Submission status: Wrong Answer

Solution code:
x =  list(map(int, input().split()))
max_per = 100*(x[4]) / 100
now_max_per = 0
ansSugarWater = 0
ansSugar = 0
for B in range(int(x[5]/(100*x[1]))):
    for A in range(int((x[5]-100*B*x[1])/(100*x[0]))+ 1):
        now_sugar = 0
        can_sugar = max_per * (x[0]*A + x[1]*B)
        if can_sugar + 100*x[0]*A + 100*x[1]*B > x[5]:
            can_sugar = x[5] - 100*x[0]*A - 100*x[1]*B
        i = [0,0]
        for D in range(int(can_sugar / x[3] + 1)):
            for C in range(int((can_sugar - D*x[3])/x[2])+ 1):
                if C*x[2] + D*x[3] > now_sugar:
                    now_sugar = C*x[2] + D*x[3]
                    i = [C, D]
        C = i[0]
        D = i[1]
        if  A == 0 and B == 0:
            continue
        elif C*x[2] + D*x[3] > can_sugar:
            continue
        elif 100*x[0]*A + 100*x[1]*B + x[2]*C + x[3]*D > x[5]:
            continue
        else:
            now_per = 100 * (C*x[2] + D*x[3]) / (100*(A*x[0] + B*x[1]) + C*x[2] + D*x[3])
        if now_per > now_max_per :
            now_max_per = now_per
            ansSugarWater = 100 * (A*x[0] + B*x[1]) + C*x[2] + D*x[3]
            ansSugar = C*x[2] + D*x[3]
print("{0} {1}".format(ansSugarWater, ansSugar))