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:

#%%
import itertools
import time
A, B, C, D, E, F = map(int,input(). split())

st = time.time()

l = list(itertools.product(range(31), repeat=2))
water = []
for i in range(len(l)):
    tmp = 0
    tmp += 100 * A * l[i][0]
    tmp += 100 * B * l[i][1]
    if tmp <= 3000:
        water.append(tmp)
l = list(itertools.product(range(1501), repeat=2))
water = list(set(water))

sugar = []
for i in range(len(l)):
    tmp = 0
    tmp += C * l[i][0]
    tmp += D * l[i][1]
    if tmp <= 1500:
        sugar.append(tmp)
sugar = list(set(sugar))

#print(len(water))
#print(len(sugar))

ans = []
for i in water:
    for j in sugar:
        if i * E >= 100 * j and i + j <= F and i + j != 0:
            tmp = [i + j, j, j/i+j]
            ans.append(tmp)

ans.sort(key=lambda x:x[2])

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







ed = time.time()
#print(ed-st)

Submission status: Wrong Answer

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

X = []
for i in range(F // (100 * A) + 1):
	for j in range((F - 100 * A * i) // (100 * B) + 1):
		X.append(100 * A * i + 100 * B * j)

Y = []
for i in range(F // C + 1):
	for j in range((F - C * i) // D + 1):
		Y.append(C * i + D * j)

concentrationMAX = 0
ans = [0,0]

for i in X:
	for j in Y:
		if i + j > 0:
			if i + j <= F:
				if i // 100 * E >= j:
					if j / (i + j) > concentrationMAX:
						concentrationMAX = j / (i + j)
						ans[0] = i + j
						ans[1] = j

print(ans[0],end=' ')
print(ans[1])

Submission status: Wrong Answer

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
# 水水砂砂濃ビ
# 1 2 10 20 15 200
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
ws = set([])
ss = set([])
ans = [100, 0]
for i in range(F // A + 1):
    for j in range((F - A * i) // B + 1):
        if 0 < A * i + B * j <= F:
            ws.add(A * i + B * j)
for i in range(F // C + 1):
    for j in range((F - C * i) // D + 1):
        if 0 < C * i + D * j <= F:
            ss.add(C * i + D * j)
for i in ws:
    for j in ss:
        if i + j <= F and j / i <= E / 100:
            if ans[1] / ans[0] < j / (i + j):
                ans = [i+j, j]
print(str(ans[0])+' '+str(ans[1]))

Submission status: Wrong Answer

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

wloop1 = f//a
dense = 0
anstot = 0
anss = 0
for i in range(wloop1+1):
    if f == a*100:
        anstot = a*100
        break
    fl = f-a*100*i
    watera = a*100*i
    wloop2 = fl//b
    for j in range(wloop2+1):
        water = watera + b*100*j
        if water == 0:
            continue
        else:
            fl = f-water
            sloop1 = fl//c
            for k in range(sloop1+1):
                sugarc = c*k
                fl = f-water-sugarc
                sloop2 = fl//d
                for l in range(sloop2+1):
                    sugar = sugarc + d*l
                    temp = sugar/(sugar+water)
                    # print(water,i,j,sugar,k,l)
                    if temp > dense and not temp > e/(100+e):
                        dense = temp
                        anstot = sugar + water
                        anss = sugar
print(anstot,anss)

Submission status: Wrong Answer

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

wloop1 = f//a
dense = 0
anstot = 0
anss = 0
for i in range(wloop1+1):
    if f == a*100:
        anstot = a*100
        break
    fl = f-a*100*i
    watera = a*100*i
    wloop2 = fl//b
    for j in range(wloop2+1):
        water = watera + b*100*j
        if water == 0:
            continue
        else:
            fl = f-water
            sloop1 = fl//c
            for k in range(sloop1+1):
                sugarc = c*k
                fl = f-water-sugarc
                sloop2 = fl//d
                for l in range(sloop2+1):
                    sugar = sugarc + d*l
                    temp = sugar/(sugar+water)
                    # print(water,i,j,sugar,k,l)
                    if temp > dense and temp <= e/(100+e):
                        dense = temp
                        anstot = sugar + water
                        anss = sugar
print(anstot,anss)

Submission status: Wrong Answer

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

wloop1 = f//a
dense = 0
anstot = 0
anss = 0
for i in range(wloop1+1):
    if f == a*100:
        anstot = a*100
        break
    fl = f-a*100*i
    watera = a*100*i
    wloop2 = fl//b
    for j in range(wloop2+1):
        water = watera + b*100*j
        if water == 0:
            continue
        else:
            fl = f-a*100*i-b*100*j
            sloop1 = fl//c
            for k in range(sloop1+1):
                sugarc = c*k
                fl = f-a*100*i-b*100*j-c*k
                sloop2 = fl//d
                for l in range(sloop2+1):
                    sugar = sugarc + d*l
                    temp = sugar/water
                    # print(water,i,j,sugar,k,l)
                    if temp > dense and temp <= e*0.01:
                        dense = temp
                        anstot = sugar + water
                        anss = sugar
print(anstot,anss)

Submission status: Wrong Answer

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

wloop1 = f//a
dense = 0
anstot = 0
anss = 0
for i in range(wloop1+1):
    fl = f-a*100*i
    watera = a*100*i
    wloop2 = fl//b
    for j in range(wloop2+1):
        water = watera + b*100*j
        if water == 0:
            continue
        else:
            fl = f-a*100*i-b*100*j
            sloop1 = fl//c
            for k in range(sloop1+1):
                sugarc = c*k
                fl = f-a*100*i-b*100*j-c*k
                sloop2 = fl//d
                for l in range(sloop2+1):
                    sugar = sugarc + d*l
                    temp = sugar/water
                    # print(water,i,j,sugar,k,l)
                    if temp > dense and temp <= e*0.01:
                        dense = temp
                        anstot = sugar + water
                        anss = sugar
print(anstot,anss)

Submission status: Wrong Answer

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

A_max = int(F / (100*A))
B_max = int(F / (100*B))
AB = []

for a in range(1, A_max+1):
    for b in range(0, B_max+1):
        if 100*A*a + 100*B*b > F: break
        AB.append(100*A*a + 100*B*b)

S_max = int(AB[-1] * E / 100)
C_max = int(S_max / C)
D_max = int(S_max / D)

max_ab = AB[-1]
max_cd = 0
max = max_cd / (max_ab + max_cd)

for ab in sorted(set(AB)):
    S = ab * E / 100
    for c in range(C_max, 0, -1):
        for d in range(D_max, -1, -1):
            cd = C*c + D*d
            if cd > S or ab + cd > F: continue
            if cd / (ab + cd) > max:
                max_ab = ab
                max_cd = cd
                max = max_cd / (max_ab + max_cd)

print(max_ab + max_cd, max_cd)

Submission status: Wrong Answer

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

A_max = int(F / (100*A))
B_max = int(F / (100*B))
AB = []

for a in range(1, A_max+1):
    for b in range(0, B_max+1):
        if 100*A*a + 100*B*b > F: break
        AB.append(100*A*a + 100*B*b)

S = int(AB[-1] * E / 100)
C_max = int(S / C)
D_max = int(S / D)

for ab in sorted(set(AB)):
    S = ab * E / 100
    for c in range(C_max, 0, -1):
        for d in range(D_max, -1, -1):
            cd = C*c + D*d
            if cd > S: continue
            if ab +cd <= F:
                print(ab+cd, cd)
                exit()

Submission status: Wrong Answer

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

A_max = int(F / (100*A))
B_max = int(F / (100*B))
AB = []

for a in range(1, A_max+1):
    for b in range(0, B_max+1):
        if 100*A*a + 100*B*b > F: break
        AB.append(100*A*a + 100*B*b)

S = int(AB[-1] * E / 100)
C_max = int(S / C)
D_max = int(S / D)

print(sorted(set(AB)))
for ab in sorted(set(AB)):
    S = ab * E / 100
    for c in range(C_max, 0, -1):
        for d in range(D_max, -1, -1):
            cd = C*c + D*d
            if cd > S: continue
            if ab +cd <= F:
                print(ab+cd, cd)
                exit()

Submission status: Wrong Answer

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

A_max = int(F / (100*A))
B_max = int(F / (100*B))
AB = []

for a in range(1, A_max+1):
    for b in range(0, B_max+1):
        if 100*A*a + 100*B*b > F: break
        AB.append(100*A*a + 100*B*b)

S = int(AB[-1] * E / 100)
C_max = int(S / C)
D_max = int(S / D)
CD = []

for c in range(1, C_max+1):
    for d in range(0, D_max+1):
        if C*c + D*d > S: break
        CD.append(C*c + D*d)

for cd in reversed(list(set(CD))):
    for ab in set(AB):
        if ab + cd <= F and ab*E/100 >= cd:
            print(ab+cd, cd)
            exit()

Submission status: Wrong Answer

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

def sol(i):
	solmax = min((i*E)//100,F-i)
	s = []
	for i in range((solmax//C)+1):
		for j in range((solmax//D)+1):
			if C*i+D*j <= solmax:
				s.append(C*i+D*j)
	s = sorted(s)
	return s[-1]

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

water = list(set(water))
suger = []
for i in range(len(water)):
	suger.append(sol(water[i]))

print(water)
print(suger)
con = 0
ws = 0
s = 0
for k in range(len(water)):
	if con <= suger[k]/(water[k]+suger[k]):
		con = suger[k]/(water[k]+suger[k])
		ws = (water[k]+suger[k])
		s = suger[k]

print(ws,s)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a_list = set([])
b_list = set([])
for i in range((f // a) + 1):
    for j in range((f // b) + 1):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.add(((a*i)+(b*j))*100)
for i in range((f // c) + 1):
    for j in range((f // d) + 1):
        if ((c*i) + (d*j)) <= f:
            b_list.add((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / aa) <= e * 100):
            if ans <= (bb / aa) * 100:
                ans = (bb / (aa)) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a_list = set([])
b_list = set([])
for i in range((f // a) + 1):
    for j in range((f // b) + 1):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.add(((a*i)+(b*j))*100)
for i in range((f // c) + 1):
    for j in range((f // d) + 1):
        if ((c*i) + (d*j)) <= f:
            b_list.add((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / aa) * 100 <= e):
            if ans <= (bb / aa) * 100:
                ans = (bb / (aa)) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a_list = set([])
b_list = set([])
for i in range((f // a) + 1):
    for j in range((f // b) + 1):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.add(((a*i)+(b*j))*100)
for i in range((f // c) + 1):
    for j in range((f // d) + 1):
        if ((c*i) + (d*j)) <= f:
            b_list.add((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / (aa + bb)) * 100 <= e):
            if ans <= (bb / (aa + bb)) * 100:
                ans = (bb / aa) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a_list = set([])
b_list = set([])
for i in range((f // a) + 1):
    for j in range((f // b) + 1):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.add(((a*i)+(b*j))*100)
for i in range((f // c) + 1):
    for j in range((f // d) + 1):
        if ((c*i) + (d*j)) <= f:
            b_list.add((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / (aa + bb) * 100) <= e):
            if ans <= (bb / (aa + bb)) * 100:
                ans = (bb / aa) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a_list = set([])
b_list = set([])
for i in range((f // a) + 1):
    for j in range((f // b) + 1):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.add(((a*i)+(b*j))*100)
for i in range((f // c) + 1):
    for j in range((f // d) + 1):
        if ((c*i) + (d*j)) <= f:
            b_list.add((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / aa) * 100 <= e):
            if ans <= (bb / (aa + bb)) * 100:
                ans = (bb / aa) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a_list = set([])
b_list = set([])
for i in range(f // a):
    for j in range(f // b):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.add(((a*i)+(b*j))*100)
for i in range(f // c):
    for j in range(f // d):
        if ((c*i) + (d*j)) <= f:
            b_list.add((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / aa) * 100 <= e):
            if ans < (bb / aa) * 100:
                ans = (bb / aa) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a_list = []
b_list = []
for i in range(f // a):
    for j in range(f // b):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.append(((a*i)+(b*j))*100)
for i in range(f // c):
    for j in range(f // d):
        if ((c*i) + (d*j)) <= f:
            b_list.append((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / aa) * 100 <= e):
            if ans < (bb / aa) * 100:
                ans = (bb / aa) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

Submission status: Wrong Answer

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

maxVal = 0
ans = (0, 0)
for aWater in range(0, F + 1, A * 100):
    for bWater in range(0, F + 1, B * 100):
        sumWater = aWater + bWater
        if sumWater == 0 or sumWater > F:
            continue
        maxSuger = sumWater * E // 100
        for cSuger in range(0, maxSuger + 1, C):
            for dSuger in range(0, maxSuger + 1, D):
                sumSuger = cSuger + dSuger
                if sumSuger + sumWater > F or sumSuger > maxSuger:
                    break
                if maxVal < sumSuger / (sumSuger + sumWater):
                    maxVal = sumSuger / (sumSuger + sumWater)
                    ans = (sumSuger + sumWater, sumSuger)

print(*ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=[a*i+b*j for i in range(31) for j in range(31) if 0<a*i+b*j<=f//100]
m=max(w)*e//min(c,d)+1
s=[c*i+d*j for i in range(m) for j in range(m) if 0<c*i+d*j<=max(w)*e]
w=sorted(list(set(w)))
s=sorted(list(set(s)))
mx=0
res=(0,0)
for p in w:
	for q in s:
		if p*100+q>f or q/p>e:
			continue
		r=100*q/(100*p+q)
		if mx<r:
			mx=r
			res=(p,q)
p,q=res
print(100*p+q,q)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
a,b = max(a,b),min(a,b)
c,d = max(c,d),min(c,d)
mcons = 0
ans = ""
for ia in range(f//(a*100)+1):
    for ib in range((f-ia*100*a)//(b*100)+1):
        water = a*100*ia+b*100*ib
        sglim = min(water//100*e,f-water)
        for ic in range(sglim//c+1):
            for i_d in range((sglim-c*ic)//d+1):
                if water>0:
                    suger = c*ic+d*i_d
                    cons = suger/(suger+water)
                    mcons = max(cons,mcons)
                    if mcons == cons:
                        ans = [water+suger,suger]
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
water = min(a,b)*100
ms = min(f-min(a,b)*100,min(a,b)*e)
x = max(c,d)
y = min(c,d)

suger = 0
for i in range(ms//x):
    suger = max(suger,ms-(ms-x*i)%y)
print(water+suger,suger)

Submission status: Wrong Answer

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

lest = f -100*a
up = min(lest,e*a)
m1 = 0
loop = up//c+1
# print(up)
# print(loop)
for i in range(loop):
    r = up-c*i
    v = r//d
    if v > 0:
        temp = c*i+v*d
    else:
        temp = c*i
    if temp > m1:
        m1 = temp

lest = f -100*b
m2 = 0
if lest > 0:
    up = min(lest,e*b)
    loop = up//c+1
    for i in range(loop):
        r = up-c*i
        v = r//d
        if v > 0:
            temp = c*i+v*d
        else:
            temp = c*i
        if temp > m2:
            m2 = temp

n1 = m1/a
n2 = m2/b

if n1 >= n2:
    print(m1+100*a,m1)
else:
    print(m2+100*b,m2)

Submission status: Wrong Answer

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

lest = f -100*a
up = min(lest,e*a)
m1 = 0
loop = up//c+1
# print(up)
# print(loop)
for i in range(loop):
    r = up-c*i
    v = r//d
    if v > 0:
        temp = c*i+v*d
    else:
        temp = c*i
    if temp > m1:
        m1 = temp

lest = f -100*b
m2 = 0
if lest > 0:
    up = min(lest,e*b)
    loop = up//c+1
    for i in range(loop):
        r = up-c*i
        v = r//d
        if c > 0:
            temp = c*i+v*d
        else:
            temp = c*i
        if temp > m2:
            m2 = temp

n1 = m1/a
n2 = m2/b

if n1 >= n2:
    print(m1+100*a,m1)
else:
    print(m2+100*b,m2)

Submission status: Wrong Answer

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

lest = f -100*a
up = min(lest,e*a)
m1 = 0
loop = up//c+1
# print(up)
# print(loop)
for i in range(loop):
    r = up-c*i
    v = r//d
    if v > 0:
        temp = c*i+v*d
    else:
        temp = c*i
    if temp > m1:
        m1 = temp

lest = f -100*b
m2 = 0
if lest > 0:
    up = min(lest,e*b)
    loop = up//c+1
    for i in range(loop):
        r = up-c*i
        v = r//d
        if c > 0:
            temp = c*i+v*d
        else:
            temp = c*i
        if temp > m2:
            m2 = temp

n1 = m1/a
n2 = m2/b

if n1 > n2:
    print(m1+100*a,m1)
else:
    print(m2+100*b,m2)

Submission status: Wrong Answer

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

max_c = 0
max_w = 0
max_s = 0

# t  = (100*e)/(100+e)

for i in range(int((f//(100*a)+1))):
  for j in range(int((f-100*a*i)//(100*b)+1)):
    for k in range(int((f-100*a*i-100*b*j)//c+1)):
      for l in range(int((f-100*a*i-100*b*j-c*k)//d+1)):
        x = 100*a*i+100*b*j
        y = c*k+d*l
        if x+y == 0:
          continue
        else:
          conc = (100*y)/(x+y)
          # print(conc)
          if max_c < conc and y <= (x*e)/100 and x+y <= f:
            max_c = conc
            max_w = x
            max_s = y
print(int(max_w+max_s), int(max_s))

Submission status: Wrong Answer

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

max_c = 0
max_w = 0
max_s = 0

# t  = (100*e)/(100+e)

for i in range(int((f//(100*a)+1))):
  for j in range(int((f-100*a*i)//(100*b)+1)):
    for k in range(int((f-100*a*i-100*b*j)//c+1)):
      for l in range(int((f-100*a*i-100*b*j-c*k)//d+1)):
        x = 100*a*i+100*b*j
        y = c*k+d*l
        if x+y == 0:
          continue
        else:
          conc = (100*y)/(x+y)
          # print(conc)
          if max_c < conc and y <= (x*e)/100:
            max_c = conc
            max_w = x
            max_s = y
print(int(max_w+max_s), int(max_s))

Submission status: Wrong Answer

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

max_c = 0
max_w = 0
max_s = 0

t  = (100*e)/(100+e)

for i in range(int((f//(100*a)+1))):
  for j in range(int((f-100*a*i)//(100*b)+1)):
    for k in range(int((f-100*a*i-100*b*j)//c+1)):
      for l in range(int((f-100*a*i-100*b*j-c*k)//d+1)):
        x = 100*a*i+100*b*j
        y = c*k+d*l
        if x == 0 or x+y == 0:
          continue
        else:
          conc = (100*y)/(x+y)
          # print(conc)
          if max_c < conc and conc <= t:
            max_c = conc
            max_w = x
            max_s = y
print(int(max_w+max_s), int(max_s))

Submission status: Wrong Answer

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

max_c = 0
max_w = 0
max_s = 0

t  = (100*e)/(100+e)

for i in range(int((f//(100*a)+1))):
  for j in range(int((f-100*a*i)//(100*b)+1)):
    for k in range(int((f-100*a*i-100*b*j)//c+1)):
      for l in range(int((f-100*a*i-100*b*j-c*k)//d+1)):
        x = 100*a*i+100*b*j
        y = c*k+d*l
        if x+y == 0:
          continue
        else:
          conc = (100*y)/(x+y)
          # print(conc)
          if max_c < conc and conc <= t:
            max_c = conc
            max_w = x
            max_s = y
print(int(max_w+max_s), int(max_s))

Submission status: Wrong Answer

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


def each_conditions(A,B,C,D,E,F):

    for an in range(30):
        if 100*A*an >= F:
            break
        for bn in range(30):
            if 100*A*an + 100*B*bn >= F:
                break

            smax = (A*an + B*bn) * E
            for cn in range(smax+1):
                if 100*A*an + 100*B*bn + C*cn > F:
                    break
                dn = (smax - cn * C) // D
                yield(an,bn,cn,dn)

def solve(A: int, B: int, C: int, D: int, E: int, F: int):

    sugerWaterM = 0
    sugerM = 0
    maxDen = 0
    for an,bn,cn,dn in each_conditions(A,B,C,D,E,F):
        wM = 100*A*an + 100*B*bn
        sM = C*cn + D*dn
        if  wM + sM <= F and sM + wM > 0:
            den = 100*(sM) / (sM+wM)
            if maxDen < den and den <= 100*E/(100+E):
                maxDen = den
                sugerWaterM = wM + sM
                sugerM = sM


    print(sugerWaterM,sugerM)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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: Wrong Answer

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


def each_conditions(A,B,C,D,E,F):

    for an in range(30):
        for bn in range(30):
            for cn in range(3000):
                if 100*A*an + 100*B*bn + C*cn > F:
                    break
                for dn in range(3000):
                    if 100*A*an + 100*B*bn + C*cn + D*dn > F:
                        break
                    yield(an,bn,cn,dn)

def solve(A: int, B: int, C: int, D: int, E: int, F: int):

    sugerWaterM = 0
    sugerM = 0
    maxDen = 0
    for an,bn,cn,dn in each_conditions(A,B,C,D,E,F):
        wM = 100*an + 100*bn
        sM = C*cn + D*dn
        if  wM + sM <= F and sM + wM > 0:
            den = 100*(sM) / (sM+wM)
            if maxDen < den and den <= 100*E/(100+E):
                maxDen = den
                sugerWaterM = wM + sM
                sugerM = sM
                if maxDen == 100*E/(100+E):
                    break


    print(sugerWaterM,sugerM)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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: Wrong Answer

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

max_conc = 0
ans_total = 0
ans_sugar = 0
for a in range(F//(100*A)+1):
    for b in range((F-a*100*A)//(100*B)+1):
        water = a * 100 * A + b * 100 * B
        if water == 0:
            continue

        for c in range((a*A+b*B)*E//C+1):
            for d in range(((a*A+b*B)*E-c*C)//D+1):
                sugar = c * C + d * D
                if sugar + water > F:
                    continue
                conc = sugar / (water + sugar)

                if max_conc < conc:
                    max_conc = conc
                    ans_total = water + sugar
                    ans_sugar = sugar

print(ans_total, ans_sugar)

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

A,B,C,D,E,F = LI()

"""
100gあたりEgとける

ABCDは何回でも行える
A,Bは100A, 100B

Fg以内で砂糖を溶け残らせてはいけない
水全体と砂糖の量を求める

濃度は100b/(a+b)

砂糖を細かく追加して、溶け残らないようにする？
2, 5あれば、4,5にできるので、組み合わせを全部試す？
ビーカー量が200gで、溶ける量が15gなら、最大でも30gまでしか溶けない
10, 20なら、10, 10, 10,と10, 20の組み合わせが考えられる
Cの最大回数とDの最大回数を求める
それぞれの量の組み合わせをすべて試す
例えば10回、10回なら、0,0/1,0/2,0...とすべて試す
"""
max_sugar_amount = int(F//(100+E)*E)
max_C_times = int(max_sugar_amount // C)
max_D_times = int(max_sugar_amount // D)
#  print('max sugar', max_sugar_amount, 'max c', max_C_times, 'max d', max_D_times)
#  exit()
ans_sugar = 0
ans_water = 0
ans_density = 0
def check_density(sugar, water, new_sugar, new_water):
    if water + sugar == 0:
        return True 
    density = (100*sugar) / (water+sugar)
    new_density = (100*new_sugar) / (new_water + new_sugar)
    return density < new_density


for i in range(1, max_C_times+1):
    #  print('i', i)
    if max_D_times == 0:
        sugar_amount = i*C
        if sugar_amount > max_sugar_amount:
            break
        else:
            # 溶け切る場合
            #  print('溶け切る')
            water_limit = F - sugar_amount
            min_water_amount = sugar_amount / E * 100
            #  print(sugar_amount, min_water_amount)
            max_A_times = int(water_limit // (A*100))
            max_B_times = int(water_limit // (B*100))
            #  print('maxA', max_A_times)
            for k in range(1, max_A_times+1):
                if max_B_times == 0:
                    # 水Bはいれられないとき
                    water = k*100*A
                    if water_limit >= water >= min_water_amount:
                        # 水の量が砂糖を溶かすのに十分 # 水量がこえていない
                        if check_density(ans_sugar, ans_water, sugar_amount, water):
                            ans_sugar = sugar_amount
                            ans_water = water
                else:
                    for l in range(0, max_B_times+1):
                        water = k*100*A + l*100*B
                        if water_limit >= water >= min_water_amount:
                            # 水の量が砂糖を溶かすのに十分
                            if check_density(ans_sugar, ans_water, sugar_amount, water):
                                ans_sugar = sugar_amount
                                ans_water = water

    for j in range(0, max_D_times+1):
        #  print(j)
        sugar_amount = i*C + j*D
        if sugar_amount > max_sugar_amount:
            break
        else:
            water_limit = F - sugar_amount
            min_water_amount = sugar_amount / E * 100
            max_A_times = int(water_limit // (A*100))
            max_B_times = int(water_limit // (B*100))
            for k in range(1, max_A_times+1):
                if max_B_times == 0:
                    water = k*100*A
                    if water_limit >= water >= min_water_amount:
                        # 水の量が砂糖を溶かすのに十分 # 水量がこえていない
                        if check_density(ans_sugar, ans_water, sugar_amount, water):
                            ans_sugar = sugar_amount
                            ans_water = water
                else:
                    for l in range(max_B_times+1):
                        water = k*100*A + l*100*B
                        if water_limit >= water >= min_water_amount:
                            if check_density(ans_sugar, ans_water, sugar_amount, water):
                                ans_sugar = sugar_amount
                                ans_water = water
print(ans_water + ans_sugar, ans_sugar)