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())
a *= 100
b *= 100

e = 100 * e / (100 + e)

res_ratio = 0
res_total = 0
res_sugar = 0

# 全探索
for a_water in range(0, f, a):
    for b_water in range(0, f - a_water, b):
        for c_sugar in range(0, f - a_water - b_water+1, c):
            for d_sugar in range(0, f - a_water - b_water - c_sugar+1, d):
                if (a_water + b_water + c_sugar + d_sugar) == 0:
                    pass
                else:
                    ratio = 100 * (c_sugar + d_sugar) / (a_water + b_water + c_sugar + d_sugar)
                    if res_ratio < ratio <= e and (a_water + b_water + c_sugar + d_sugar) <= f:
                        res_total = (a_water + b_water + c_sugar + d_sugar)
                        res_sugar = c_sugar + d_sugar
                        res_ratio = ratio
                    elif ratio > e:
                        break
print(res_total, res_sugar)

Submission status: Wrong Answer

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

e = 100 * e / (100 + e)

res_ratio = 0
res_total = 0
res_sugar = 0

# 全探索
for a_water in range(0, f, a):
    for b_water in range(0, f - a_water, b):
        for c_sugar in range(0, f - a_water - b_water, c):
            for d_sugar in range(0, f - a_water - b_water - c_sugar, d):
                if (a_water + b_water + c_sugar + d_sugar) == 0:
                    pass
                else:
                    ratio = 100 * (c_sugar + d_sugar) / (a_water + b_water + c_sugar + d_sugar)
                    if res_ratio < ratio <= e and (a_water + b_water + c_sugar + d_sugar) <= f:
                        res_total = (a_water + b_water + c_sugar + d_sugar)
                        res_sugar = c_sugar + d_sugar
                        res_ratio = ratio
                    elif ratio > e:
                        break
print(res_total, res_sugar)

Submission status: Wrong Answer

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

lim_ratio = e/(e+100)*100
water = []
sugar = 0

# waterの候補
for a_water in range(f//a+1):
    if a*a_water != 0:
        water.append(a*a_water)
    for b_water in range((f-a_water*a)//b):
        if a*a_water+b*b_water != 0:
            water.append(a*a_water+b*b_water)

set_water = sorted(set(water))

res_total = 0
res_sugar = 0
res_ratio = 0

# sugarの候補
for water in set_water:

    for c_ratio in range((f-water)//c+1):
        c_sugar = c_ratio*c
        tmp_res = 100 * c_sugar / (c_sugar + water)
        if tmp_res > lim_ratio:
            break
        if res_ratio < tmp_res:
            res_ratio = tmp_res
            res_sugar = c_sugar
            res_total = c_sugar+water

        for d_ratio in range((f-water-c_sugar)//d+1):
            d_sugar = d*d_ratio
            if c_sugar + d_sugar != 0:
                tmp_res = 100 * (c_sugar + d_sugar) / (c_sugar + d_sugar + water)
                if tmp_res > lim_ratio:
                    break
                if res_ratio < tmp_res:
                    res_ratio = tmp_res
                    res_sugar = c_sugar + d_sugar
                    res_total = water+(c_sugar + d_sugar)

print(res_total, res_sugar)

Submission status: Wrong Answer

Solution code:


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

waters = []
for i in range(f // (100 * a) + 1):
    for j in range(f // (100 * b) + 1):
        amount = 100 * (i * a + j * b)
        if amount <= f:
            waters.append(100 * i * a + 100 * j * b)

sugers = []
for i in range(f // c + 1):
    for j in range(f // d + 1):
        amount = i * c + j * d
        if amount <= f:
            sugers.append(i * c + j * d)

maxp = 0.0
res_w = 0
res_s = 0

for w in waters:
    for s in sugers:
        if w + s > f or w + s == 0:
            continue
        capa = w // 100 * e
        if s > capa:
            continue
        p = 100 * s / (w + s)
        if maxp < p:
            maxp, res_w, res_s = p, w + s, s

print("%d %d" % (res_w, res_s))

Submission status: Wrong Answer

Solution code:


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

waters = []
for i in range(f // (100 * a) + 1):
    for j in range(f // (100 * b) + 1):
        amount = 100 * (i * a + j * b)
        if amount <= e:
            waters.append(100 * i * a + 100 * j * b)

sugers = []
for i in range(f // c + 1):
    for j in range(f // d + 1):
        amount = i * c + j * d
        if amount <= e:
            sugers.append(i * c + j * d)

maxp = 0.0
res_w = 0
res_s = 0

for w in waters:
    for s in sugers:
        if w + s > f or w + s == 0:
            continue
        capa = w // 100 * e
        if s > capa:
            continue
        p = 100 * s / (w + s)
        if maxp < p:
            maxp, res_w, res_s = p, w + s, s

print("%d %d" % (res_w, res_s))

Submission status: Wrong Answer

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

ans_cons = 0
whole_weight = 0
suger_weight = 0

water = []
suger = []

for i in range(f//(100*a)+1):
  for j in range(f//(100*a)+1):
    w = 100 * a * i + 100 * b * j
    if w <= f:
      water.append(w)

for k in range(f-(100*a)+1):
  for l in range(f-(100*a)+1):
    s = c * k + d * l
    if s <= f:
      suger.append(s)
for wa in water:
  for su in suger:
    if (wa + su) == 0:
      continue
    if (wa + su) > f:
      continue
    cons = su * 100 / (wa + su)
    limit = e * 100 / (100 + e)

    if cons > limit:
      continue

    if cons > ans_cons:
      ans_cons = cons
      whole_weight = wa + su
      suger_weight = su

print("{} {}".format(whole_weight, suger_weight))

Submission status: Wrong Answer

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

ans_cons = 0
whole_weight = 0
suger_weight = 0

water = []
suger = []

for i in range(f):
  for j in range(f):
    w = 100 * a * i + 100 * b * j
    if w <= f:
      water.append(w)

for k in range(f):
  for l in range(f):
    s = c * k + d * l
    if s <= f:
      suger.append(s)

for wa in water:
  for su in suger:
    if (wa + su) == 0:
      continue
    if (wa + su) > f:
      continue
    cons = su * 100 / (wa + su)
    limit = e * 100 / (100 + e)

    if cons > limit:
      continue

    if cons > ans_cons:
      ans_cons = cons
      whole_weight = wa + su
      suger_weight = su

print("{} {}".format(whole_weight, suger_weight))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
ans_pow = 0
whole_weight = 0
suger_weight = 0 
for i in range(f // (100*a) + 1):
	for j in range(f):
		water = 100 * a * i + 100 * b * j
		suger = c * i + d * j
		if (water + suger) == 0:
  			continue
		if (water+suger) > f:
  			continue
		power = suger / (water + suger)

		if power > (e / 100 + e):
			continue
		if power > ans_pow:
			ans_pow = power
			whole_weight = water + suger
			suger_weight = suger

print("{} {}".format(whole_weight, suger_weight))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=[int(i) for i in input().split(' ')]
a=a*100
b=b*100
am = f//a
bm = f//b
cm = int((f/((100+e)/e))//c)
dm = int((f/((100+e)/e))//d)


yl=0
yn=0
ys=0
for i_a in range(am+1):
  la=i_a*a
  for i_b in range(bm+1):
    lb=i_b*b
    if 0<la+lb<=f:
      for i_c in range(cm+1):
        lc=i_c*c
        if 0<la+lb+lc<=f:
          for i_d in range(dm+1):
            ld=i_d*d
            if 0<la+lb+lc+ld<=f:
              if (lc+ld)/(la+lb+lc+ld) <= e/(100+e):
                n=(lc+ld)/(la+lb+lc+ld)
                if n > yn:
                  yn=n
                  yl=la+lb+lc+ld
                  ys=lc+ld
print(yl,ys)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=[int(i) for i in input().split(' ')]
a=a*100
b=b*100
am = f//a
bm = f//b
cm = int((f/((100+e)/e))//c)
dm = int((f/((100+e)/e))//d)

yl=0
yn=0
ys=0
for i_a in range(am):
  la=i_a*a
  for i_b in range(bm):
    lb=i_b*b
    if 0<la+lb<=f:
      for i_c in range(cm):
        lc=i_c*c
        if 0<la+lb+lc<=f:
          for i_d in range(dm):
            ld=i_d*d
            if 0<la+lb+lc+ld<=f:
              if (lc+ld)/(la+lb+lc+ld) <= e/(100+e):
                n=(lc+ld)/(la+lb+lc+ld)
                if n > yn:
                  yn=n
                  yl=la+lb+lc+ld
                  ys=lc+ld
print(yl,ys)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=[int(i) for i in input().split(' ')]
a=a*100
b=b*100
am = f//a
bm = f//b
cm = int((f/((100+e)/e))//c)
dm = int((f/((100+e)/e))//d)
print(a,b,c,d,am,bm,cm,dm)

yl=0
yn=0
ys=0
for i_a in range(am):
  la=i_a*a
  for i_b in range(bm):
    lb=i_b*b
    if 0<la+lb<=f:
      for i_c in range(cm):
        lc=i_c*c
        if 0<la+lb+lc<=f:
          for i_d in range(dm):
            ld=i_d*d
            if 0<la+lb+lc+ld<=f:
              if (lc+ld)/(la+lb+lc+ld) <= e/(100+e):
                n=(lc+ld)/(la+lb+lc+ld)
                if n > yn:
                  yn=n
                  yl=la+lb+lc+ld
                  ys=lc+ld
print(yl,ys)

Submission status: Wrong Answer

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

INF = 100
ans = 0
ans2 = [A, 0]
for i in range(INF):
    if A * 100 * i > F:
        break

    for j in range(INF):
        if A * 100 * i + B * 100 * j > F:
            break

        for k in range(INF):
            if A * 100 * i + B * 100 * j + C * k > F:
                break

            for l in range(INF):
                if A * 100 * i + B * 100 * j + C * k + D * l > F:
                    break

                if i == 0 and j == 0 and k == 0 and l == 0:
                    continue
                tmp = (C * k + D * l) / (A * 100 * i + B * 100 * j + C * k + D * l) 
                if tmp <= E / (E + 100) and tmp > ans:
                    ans = tmp
                    ans2[0] = A * 100 * i + B * 100 * j + C * k + D * l
                    ans2[1] = C * k + D * l
print("%d %d" % (ans2[0], ans2[1]))

Submission status: Wrong Answer

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

AMAX = F // (A * 100)
BMAX = F // (B * 100)
sugar = 0
water = min(A,B)*100

res = 0
for i in range(AMAX + 1):
	for j in range(BMAX + 1):
		if i == 0 and j == 0:
			continue
		cwater = A * i + B * j
		CMAX = (F - cwater * 100) // C
		DMAX = (F - cwater * 100) // D
		for k in range(CMAX + 1):
			for l in range(DMAX + 1):
				if k == 0 and l == 0:
					continue
				csugar = k * C + l * D
				if cwater * E < csugar:
					break;
				if F < cwater * 100 + csugar:
					break;
				if res < csugar / (cwater * 100 + csugar):
					water = cwater
					sugar = csugar
					res = csugar / (cwater * 100 + csugar)

print(water + sugar, sugar)

Submission status: Wrong Answer

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

AMAX = F // (A * 100)
BMAX = F // (B * 100)
sugar = 0
water = min(A,B)*100

res = 0
for i in range(AMAX + 1):
	for j in range(BMAX + 1):
		if i == 0 and j == 0:
			continue
		cwater = A * i + B * j
		CMAX = (F - cwater * 100) // 100
		DMAX = (F - cwater * 100) // 100
		for k in range(CMAX + 1):
			for l in range(DMAX + 1):
				if k == 0 and l == 0:
					continue
				csugar = k * C + l * D
				if cwater * E < csugar:
					break;
				if F < cwater * 100 + csugar:
					break;
				if res < csugar / (cwater * 100 + csugar):
					water = cwater
					sugar = csugar
					res = csugar / (cwater * 100 + csugar)

print(water + sugar, sugar)

Submission status: Wrong Answer

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

water = 0
sugar = 0
res = 0
for i in range(0,F+1):
	for j in range(0,F - 100 * A * i+1):
		if i == 0 and j == 0:
			continue
		cwater = 100 * A * i + 100 * B * j
		for m in range(F - cwater, -1,-1):
			for k in range(F - cwater - m * D, -1,-1):
				if k == 0 and m == 0:
					continue
				csugar = k * C + m * D
				if E * cwater >= 100 * csugar and res < 100 * csugar / (cwater + csugar):
					water = cwater
					sugar = csugar
					res = 100 * csugar / (cwater + csugar)
#					print(water + sugar, sugar)
#					sys.exit()
print(water + sugar, sugar)

Submission status: Wrong Answer

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

water = 0
sugar = 0
res = 0
for i in range(0,F):
	for j in range(0,F - 100 * A * i):
		if i == 0 and j == 0:
			continue
		cwater = 100 * A * i + 100 * B * j
		for m in range(F - cwater, -1,-1):
			for k in range(F - cwater - m * D, -1,-1):
				if k == 0 and m == 0:
					continue
				csugar = k * C + m * D
				if E * cwater >= 100 * csugar and res < 100 * csugar / (cwater + csugar):
					water = cwater
					sugar = csugar
					res = 100 * csugar / (cwater + csugar)
#					print(water + sugar, sugar)
#					sys.exit()
print(water + sugar, sugar)

Submission status: Wrong Answer

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

water = 0
sugar = 0
res = 0
for i in range(0,F):
	for j in range(0,F - 100 * A * i):
		if i == 0 and j == 0:
			continue
		for k in range(0,F - 100 * A * i - 100 * B * j):
			for m in range(0,F - 100 * A * i - 100 * B * j - k * C):
				if k == 0 and m == 0:
					continue
				if E * (100 * A * i + 100 * B * j)  >= 100 * (k * C + m * D) and res < 100 * (k * C + m * D) / (100 * A * i + 100 * B * j + k * C + m * D):
					res = 100 * (k * C + m * D) / (100 * A * i + 100 * B * j + k * C + m * D)
					water = 100 * A * i + 100 * B * j
					sugar = k * C + m * D

print(water + sugar, sugar)

Submission status: Wrong Answer

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

water = 0
sugar = 0
res = 0
for i in range(0,F):
	for j in range(0,F - 100 * A * i):
		if i == 0 and j == 0:
			continue
		for m in range(F - 100 * A * i - 100 * B * j, -1,-1):
			for k in range(F - 100 * A * i - 100 * B * j - m * D, -1,-1):
				if k == 0 and m == 0:
					continue
				if E * (100 * A * i + 100 * B * j)  >= 100 * (k * C + m * D) and res < 100 * (k * C + m * D) / (100 * A * i + 100 * B * j + k * C + m * D):
					water = 100 * A * i + 100 * B * j
					sugar = k * C + m * D
					res = 100 * (k * C + m * D) / (100 * A * i + 100 * B * j + k * C + m * D)
#					print(water + sugar, sugar)
#					sys.exit()
print(water + sugar, sugar)

Submission status: Wrong Answer

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

water = 0
sugar = 0
res = 0
for i in range(0,F):
	for j in range(0,F - 100 * A * i):
		if i == 0 and j == 0:
			continue
		for m in range(F - 100 * A * i - 100 * B * j, -1,-1):
			for k in range(F - 100 * A * i - 100 * B * j - m * D, -1,-1):
				if k == 0 and m == 0:
					continue
				if E * (100 * A * i + 100 * B * j)  >= 100 * (k * C + m * D) and res < 100 * (k * C + m * D) / (100 * A * i + 100 * B * j + k * C + m * D):
					water = 100 * A * i + 100 * B * j
					sugar = k * C + m * D
					print(water + sugar, sugar)
					sys.exit()

Submission status: Wrong Answer

Solution code:
import math

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

maxdens = 0.0
maxsugar = 0
maxwater = 0

for ai in range(30+1):
    for bi in range(30+1):
        for ci in range(100+1):
            for di in range(100+1):
                sugar = ci*c + di*d
                water = ai*a*100 + bi*b*100
                if water == 0 or ( sugar + water ) > f :
                    break
                else:
                    dens = 100.0 * (sugar / (sugar+water) )
                    if dens > 100.0*(e/(100.0+e)):
                        break
                    else:
                        if maxdens < dens:
                            maxdens = dens
                            maxsugar = sugar
                            maxwater = water
                            # print(ai,bi,ci,di,dens)

print((maxsugar+maxwater), maxsugar )

Submission status: Wrong Answer

Solution code:
import math

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

maxdens = 0.0
maxsugar = 0
maxwater = 0

maxa = math.ceil(f / (100*a))
for ai in range(maxa+1):
    maxb = math.ceil( (f-(100*a*ai)) / (100*b))
    for bi in range(maxb+1):
        maxc = math.ceil( ( f-(100*a*ai + 100*b*bi))/c  )
        for ci in range(maxc+1):
            maxd = math.ceil( ( f-(100*a*ai + 100*b*bi + c*ci))/d  )
            for di in range(maxd+1):
                sugar = ci*c + di*c
                water = ai*a*100 + bi*b*100
                if water == 0 or ( sugar + water ) > f :
                    break
                else:
                    dens = 100.0 * (sugar / (sugar+water) )
                    if dens > 100.0*(e/(100.0+e)):
                        break
                    else:
                        if maxdens < dens:
                            maxdens = dens
                            maxsugar = sugar
                            maxwater = water
                            # print(ai,bi,ci,di,dens)

print((maxsugar+maxwater), maxsugar )

Submission status: Wrong Answer

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

w = 0
s = 0
ratio = 0

for i in range((f // (b*100))+1):
    for j in range(((f-(i*b*100))//a)+1):
        if i == 0 and j == 0:
            continue
        smax = min(f-(j*a+i*b)*100,(j*a+i*b)*e)
        sm = 0
        for k in range((smax//d)+1):
            sm = max(sm, k*d+c*((smax-(k*d))//c))
        if ratio <= sm/((j*a+i*b)*100+sm):
            ratio = sm/((j*a+i*b)*100+sm)
            w = (j*a+i*b)*100
            s = sm

if w+s == 0:
    w = 100*a

print("%i %i" %(w+s,s))

Submission status: Wrong Answer

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

w = 0
s = 0
ratio = 0

for i in range((f // (b*100))+1):
    for j in range(((f-(i*b*100))//a)+1):
        if i == 0 and j == 0:
            continue
        smax = min(f-(j*a+i*b)*100,(j*a+i*b)*e)
        sm = 0
        for k in range((smax//d)+1):
            sm = max(sm, k*d+c*((smax-(k*d))//c))
        if ratio <= sm/((j*a+i*b)*100+sm):
            ratio = sm/((j*a+i*b)*100+sm)
            w = (j*a+i*b)*100
            s = sm



print("%i %i" %(w+s,s))

Submission status: Wrong Answer

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

w = 0
s = 0
ratio = 0

for i in range((f // (b*100))+1):
    for j in range(((f-(i*b*100))//a)+1):
        if i == 0 and j == 0:
            continue
        if(j*a+i*b > f):exit(1)
        smax = min(f-(j*a+i*b)*100,(j*a+i*b)*e)
        sm = 0
        for k in range((smax//d)+1):
            sm = max(sm, k*d+c*((smax-(k*d))//c))
            if(sm > smax):exit(1)
        if ratio < sm/((j*a+i*b)*100+sm):
            ratio = sm/((j*a+i*b)*100+sm)
            w = (j*a+i*b)*100
            s = sm



print("%i %i" %(w+s,s))

Submission status: Wrong Answer

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

w = 0
s = 0
ratio = 0

for i in range((f // (b*100))+1):
    for j in range(((f-(i*b*100))//a)+1):
        if i == 0 and j == 0:
            continue
        smax = min(f-(j*a+i*b)*100,(j*a+i*b)*e)
        print('smax is %s' %(smax))
        sm = 0
        for k in range((smax//d)+1):
            sm = max(sm, k*d+c*((smax-(k*d))//c))
            print('sm is %s' %(sm))
        if ratio <= sm/((j*a+i*b)*100+sm):
            ratio = sm/((j*a+i*b)*100+sm)
            w = (j*a+i*b)*100
            s = sm



print("%i %i" %(w+s,s))

Submission status: Wrong Answer

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

w = 0
s = 0
ratio = 0

for i in range((f // (b*100))+1):
    for j in range(((f-(i*b*100))//a)+1):
        if i == 0 and j == 0:
            continue
        smax = min(f-(j*a+i*b)*100,(j*a+i*b)*e)
        sm = 0
        for k in range((smax//d)+1):
            sm = max(sm, k*d+c*((smax-(k*d))//c))
        if ratio < sm/((j*a+i*b)*100+sm):
            ratio = sm/((j*a+i*b)*100+sm)
            w = (j*a+i*b)*100
            s = sm



print("%i %i" %(w+s,s))

Submission status: Wrong Answer

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

w = 0
s = 0
ratio = 0

for i in range((f // (b*100))+1):
    for j in range(((f-(i*b*100))//a)+1):
        if i == 0 and j == 0:
            continue
        smax = min(f-(j*a+i*b)*100,(j*a+i*b)*e)
        sm = 0
        for k in range((smax//d)+1):
            sm = max(sm, k*d+c*((smax-(k*d))//c))
#        if ratio < sm/((j*a+i*b)*100+sm):
            ratio = sm/((j*a+i*b)*100+sm)
            w = (j*a+i*b)*100
            s = sm



print("%i %i" %(w+s,s))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

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

    water_list = []
    sugar_list = []

    i, j = 0, 0
    while A * 100 * i <= F:
        while A * 100 * i + B * 100 * j <= F:
            water_list.append(A * 100 * i + B * 100 * j)
            j += 1
        i += 1
        j = 0

    i, j = 0, 0
    while C * i <= F:
        while C * i + D * j <= F:
            sugar_list.append(C * i + D * j)
            j += 1
        i += 1
        j = 0

    max_sugar_water_per = 0
    max_water = 0
    max_sugar = 0
    for water in water_list:
        for sugar in sugar_list:
            if water == 0 :
                continue
            sugar_water_per = 100 * sugar / (water + sugar)
            if sugar <= E * water / 100 and water + sugar <= F and max_sugar_water_per < sugar_water_per:
                max_sugar_water_per = sugar_water_per
                max_water = water
                max_sugar = sugar

    print("{} {}".format(max_water + max_sugar, max_sugar))
                    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

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

    water_list = []
    sugar_list = []

    i, j = 0, 0
    while A * 100 * i <= F:
        while A * 100 * i + B * 100 * j <= F:
            water_list.append(A * 100 * i + B * 100 * j)
            j += 1
        i += 1
        j = 0

    i, j = 0, 0
    while C * i <= F:
        while C * i + D * j <= F:
            sugar_list.append(C * i + D * j)
            j += 1
        i += 1
        j = 0

    max_sugar_water_per = 0
    max_water = 0
    max_sugar = 0
    for water in water_list:
        for sugar in sugar_list:
            if water == 0 :
                continue
            sugar_water_per = 100 * sugar / (water + sugar)
            if sugar <= E and water + sugar <= F and max_sugar_water_per < sugar_water_per:
                max_sugar_water_per = sugar_water_per
                max_water = water
                max_sugar = sugar

    print("{} {}".format(max_water + max_sugar, max_sugar))
                    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

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

    water_list = []
    sugar_list = []

    i, j = 0, 0
    while A * 100 * i <= F:
        while A * 100 * i + B * 100 * j <= F:
            water_list.append(A * 100 * i + B * 100 * j)
            j += 1
        i += 1
        j = 0

    i, j = 0, 0
    while C * i <= F:
        while C * i + D * j <= F:
            sugar_list.append(C * i + D * j)
            j += 1
        i += 1
        j = 0

    max_sugar_water_per = 0
    max_water = 0
    max_sugar = 0
    for water in water_list:
        for sugar in sugar_list:
            if water == 0 :
                continue
            sugar_water_per = 100 * sugar / (water + sugar)
            if sugar_water_per <= E and water + sugar <= F and max_sugar_water_per < sugar_water_per:
                max_sugar_water_per = sugar_water_per
                max_water = water
                max_sugar = sugar

    print("{} {}".format(max_water + max_sugar, max_sugar))
                    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
x = [int(i) for i in input().split()]
A = x[0]
B = x[1]
C = x[2]
D = x[3]
E = x[4]
F = x[5]

# とりうる水の量
WATER_MAX = int(F/100)
water = [False for i in range(WATER_MAX+1)]
tmp = 0
water_smaller = min(A,B)
water_bigger = max(A,B)
while(1):
    if(tmp>WATER_MAX):
        break
    water[tmp]=True
    sum = tmp + water_bigger
    while(sum<=WATER_MAX):
        water[sum] = True
        sum+=water_bigger
    tmp+=water_smaller

#とりうる砂糖の量の最大
suger_max = [0 for i in range(WATER_MAX+1)]
suger_smaller = min(C,D)
suger_bigger = max(C,D)
water_amount = 0
for i in range(1,WATER_MAX+1):
    tmp_max = 0
    water_amount = 100*i
    if(water[i]==False):
        continue
    SUGER_MAX=i*E
    tmp = 0
    while(1):
        if(tmp>SUGER_MAX):
            break
        if(tmp+water_amount>F):
            break
        if(tmp_max<=tmp):
            tmp_max = tmp
        sum = tmp + suger_bigger
        while(sum<=SUGER_MAX and sum+water_amount<F):
            if(tmp_max<=sum):
                tmp_max = sum
            sum+=suger_bigger
        tmp+=suger_smaller
    suger_max[i] = tmp_max

#最大の濃度の検索
max_conc = 0.001
max_index = 0
for i in range(1,WATER_MAX+1):
    conc = suger_max[i] / (100.0*i+suger_max[i])
    if(conc>max_conc):
        max_conc = conc
        max_index = i

print(100*max_index+suger_max[max_index],suger_max[max_index])

Submission status: Wrong Answer

Solution code:
x = [int(i) for i in input().split()]
A = x[0]
B = x[1]
C = x[2]
D = x[3]
E = x[4]
F = x[5]

# とりうる水の量
WATER_MAX = int(F/100)
water = [False for i in range(WATER_MAX+1)]
tmp = 0
water_smaller = min(A,B)
water_bigger = max(A,B)
while(1):
    if(tmp>WATER_MAX):
        break
    water[tmp]=True
    sum = tmp + water_bigger
    while(sum<=WATER_MAX):
        water[sum] = True
        sum+=water_bigger
    tmp+=water_smaller

#とりうる砂糖の量の最大
suger_max = [0 for i in range(WATER_MAX+1)]
suger_smaller = min(C,D)
suger_bigger = max(C,D)
water_amount = 0
for i in range(1,WATER_MAX+1):
    tmp_max = 0
    water_amount = 100*i
    if(water[i]==False):
        continue
    SUGER_MAX=i*E
    tmp = 0
    while(1):
        if(tmp>SUGER_MAX):
            break
        if(tmp+water_amount>F):
            break
        if(tmp_max<=tmp):
            tmp_max = tmp
        sum = tmp + suger_bigger
        while(sum<=SUGER_MAX and sum+water_amount<F):
            if(tmp_max<=sum):
                tmp_max = sum
            sum+=suger_bigger
        tmp+=suger_smaller
    suger_max[i] = tmp_max

#最大の濃度の検索
max_conc = 0.0
max_index = 0
for i in range(1,WATER_MAX+1):
    conc = suger_max[i] / (100.0*i+suger_max[i])
    if(conc>max_conc):
        max_conc = conc
        max_index = i

print(100*max_index+suger_max[max_index],suger_max[max_index])