Problem:


Score : 300 points

Problem Statement

Snuke is making sugar water in a beaker.
Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.

Operation 1: Pour 100A grams of water into the beaker.

Operation 2: Pour 100B grams of water into the beaker.

Operation 3: Put C grams of sugar into the beaker.

Operation 4: Put D grams of sugar into the beaker.

In our experimental environment, E grams of sugar can dissolve into 100 grams of water.

Snuke will make sugar water with the highest possible density.

The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.
Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.
If there is more than one candidate, any of them will be accepted.

We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent.
Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.

Constraints

1 \leq A < B \leq 30

1 \leq C < D \leq 30

1 \leq E \leq 100

100A \leq F \leq 3 000

A, B, C, D, E and F are all integers.

Inputs

Input is given from Standard Input in the following format:

A B C D E F

Outputs

Print two integers separated by a space.
The first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.

Sample Input 1

1 2 10 20 15 200

Sample Output 1

110 10

In this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.

We can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.
It is not possible to make sugar water with higher density.
For example, the following sequences of operations are infeasible:

If we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.

If we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.

Sample Input 2

1 2 1 2 100 1000

Sample Output 2

200 100

There are other acceptable outputs, such as:

400 200

However, the output below is not acceptable:

300 150

This is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.

Sample Input 3

17 19 22 26 55 2802

Sample Output 3

2634 934



Sample input:
1 2 10 20 15 200


Sample output:
110 10

Submission status: Accepted

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

temp = 0
ans1, ans2 = 100 * A, 0

for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                w = 100 * A * i + 100 * B * j
                s = C * k + D * l
                if w == 0:
                    break
                if s > E * (A * i + B * j):
                    break
                if w + s > F:
                    break
                if s / (w + s) > temp:
                    temp = s / (w + s)
                    ans1 = w + s
                    ans2 = s

print(ans1, ans2)

Submission status: Accepted

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

maxr = 0
result = 0, 0

for a in range(31):
    for b in range(31):
        l = 100 * a * A + 100 * b * B
        if l <= F:
            maxs100 = E * l
            d = 0
            while d * D * 100 <= maxs100:
                c1 = (maxs100 - d * D * 100) // (C * 100)
                c2 = (F - l - d * D) // C
                c = min(c1, max(0, c2)) 
                s = c * C + d * D
                w = l + s
                if 0 < w <= F:
                    r = 100 * s / w
                    if r >= maxr:
                        maxr = r
                        result = w, s
                d += 1

print(*result)

Submission status: Accepted

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

w = []
i = -1
while True:
    i += 1
    if a*i > f:
        break
    j = -1
    while True:
        j += 1
        if a*i+b*j > f:
            break
        w.append(a*i+b*j)
w = list(set(w))

s = []
i = -1
while True:
    i += 1
    if c*i > f:
        break
    j = -1
    while True:
        j += 1
        if c*i+d*j > f:
            break
        s.append(c*i+d*j)
s = list(set(s))

ans = [0, 0, 0]
for y in w:
    if y == 0:
        continue
    for x in s:
        if x+y <= f and e*y//100 >= x:
            ans = max(ans, [x/y, x+y, x])

txt = str(ans[1]) + " " + str(ans[2])
print(txt)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
max_con = (100*E)/(100+E)
W,S = [],[]
for i in range(0,F+1,100*A):
    j = 0
    while i+100*B*j<=F:
        W.append(i+100*B*j)
        j += 1
setW = set(W)
for i in range(0,F+1,C):
    j = 0
    while i+D*j<=F:
        S.append(i+D*j)
        j += 1
setS = set(S)
con = -1
total, ans_s = 0,0
for w in setW:
    for s in setS:
        if w==s==0:
            continue
        if (100*s)/(w+s)<=max_con and s+w<=F and con<(100*s)/(w+s):
            con = (100*s)/(w+s)
            total = w+s
            ans_s = s
print(total, ans_s)

Submission status: Accepted

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


def create_candidates(w_x, w_y, F):
    """
    >>> create_candidates(2,11,15)
    {0, 2, 4, 6, 8, 10, 11, 12, 13, 14, 15}
    """
    candidates = set()
    for x in range(F):
        if w_x * x > F:
            break
        for y in range(F):
            a = w_x * x + w_y * y
            if a <= F:
                candidates.add(a)
            else:
                break
    return candidates


candidates_a = create_candidates(100 * A, 100 * B, F)
candidates_b = create_candidates(C, D, F)
candidates_a.remove(0)

max_dense = -float("inf")
max_a = -1
max_b = -1
for a in candidates_a:
    for b in candidates_b:
        if a + b <= F and b <= a * E / 100 and 100 * b / (a + b) > max_dense:
            max_dense = 100 * b / (a + b)
            max_a = a
            max_b = b

print(max_a + max_b, max_b)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = 1
sugar = -1
for w_a in range(0, F + 1, 100 * A):
    for w_b in range(0, F - w_a + 1, 100 * B):
        new_w = w_a + w_b
        if new_w == 0:
            continue
        G = min(F - new_w, new_w * E // 100)
        for s_c in range(0, G + 1, C):
            for s_d in range(0, G - s_c + 1, D):
                new_s = s_c + s_d
                if sugar / water < new_s / new_w:
                    water = new_w
                    sugar = new_s
print(water + sugar, sugar)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = 1
sugar = -1
for w_a in range(0, F + 1, 100 * A):
    for w_b in range(0, F - w_a + 1, 100 * B):
        new_w = w_a + w_b
        if new_w == 0:
            continue
        G = min(F - new_w, new_w * E // 100)
        for s_c in range(0, G + 1, C):
            for s_d in range(0, G - s_c + 1, D):
                new_s = s_c + s_d
                if sugar * new_w < new_s * water:
                    water = new_w
                    sugar = new_s
print(water + sugar, sugar)

Submission status: Accepted

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


noudo=0

satomizu=0
sato=0
Flug=False

NA1=F/(A*100)
NA=int(NA1)
NB1=F/(B*100)
NB=int(NB1)
NC1=F/C
NC=int(NC1)
ND1=F/D
ND=int(ND1)
if B%A ==0:
    NB=1
if D%C ==0:
    ND=1

jyogen=E/(100+E)
for a in range(1,NA+2):
    for b in range(NB+1):
        for c in range(NC+1):
            for d in range(ND+1):
                if  noudo<=(c*C+d*D)/(100*a*A +100*b*B+c*C+d*D) and (c*C+d*D)/(100*a*A +100*b*B+c*C+d*D)<=jyogen and (100*a*A +100*b*B+c*C+d*D)<=F:
                    noudo=(c*C+d*D)/(100*a*A +100*b*B+c*C+d*D)
                    satomizu=100*a*A +100*b*B+c*C+d*D
                    sato=c*C+d*D
                    if sato/satomizu == jyogen:
                        Flug=True
                        break
    if Flug==True:
            break
print(str(satomizu)+" "+str(sato))

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
water=[]
suguar=[]
for i in range((f+1)//100):
    for j in range((f+1)//100):
        x=100*i*a+100*j*b
        if 1<=x<=f:
            water.append(x)
for i in range(f+1):
    for j in range(f+1):
        y=c*i+d*j
        if y<=f:
            suguar.append(y)
ans=0
for i in water:
    for j in suguar:
        total=i+j
        if total<=f:
            if j<=i//100*e:
                con=100*j/(i+j)
                if ans<=con:
                    ans=con
                    ans_2=total
                    ans_3=j
print(ans_2,ans_3)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = list(map(int, input().split()))
 
water = [1]
for i in range(30):
	water.append(0)
 
for i in range(31):
	if water[i] == 1:
		if (i + A) * 100 <= F:
			water[i + A] = 1
 
		if (i + B) * 100 <= F:
			water[i + B] = 1
 
K = []
 
for i in range(1, 31):
	if water[i] == 1:
		sugar = [1]
		X = min(i * E, F - 100 * i)
		for j in range(X):
			sugar.append(0)
 
		for j in range(X + 1):
			if sugar[j] == 1:
				if j + C <= X:
					sugar[j + C] = 1
 
				if j + D <= X:
					sugar[j + D] = 1
		sugar.reverse()
		s = sugar.index(1)
		WS = ((100 * (X - s) / (100 * i + X - s)), 100 * i + X - s, X - s)
		K.append(WS)
 
K = sorted(K)
print(K[-1][1], K[-1][2])

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
water=[]
sugar=[]
ans,ans_2,con=0,0,0
for i in range(f//100+1):#f//100+1によりTLEを解消
    for j in range(f//100+1):
        x=100*a*i+100*j*b
        if 0<x<=f:
            water.append(x)
for i in range(f):
    for j in range(f):
        y=c*i+d*j
        if y<=f:
            sugar.append(y)
sugar=list(set(sugar))
for i in water:
    for j in sugar:
        if i+j<=f:
            if j<=i//100*e:
                now=(100*j)/(i+j)
                if con<=now:
                    ans=i+j
                    ans_2=j
                    con=now
print(ans,ans_2)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
water=[]
sugar=[]
ans,ans_2,con=0,0,0
for i in range(f//100+1):#f//100+1によりTLEを解消
    for j in range(f//100+1):
        x=100*a*i+100*j*b
        if x<=f:
            water.append(x)
for i in range(f):
    for j in range(f):
        y=c*i+d*j
        if y<=f:
            sugar.append(y)
sugar=list(set(sugar))
for i in water:
    for j in sugar:
        if i+j<=f:
            if i!=0 or j!=0:
                if j<=(i//100)*e:
                    now=(100*j)/(i+j)
                    if con<=now:
                        ans=i+j
                        ans_2=j
                        con=now
print(ans,ans_2)

Submission status: Accepted

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

a=set()
for i in range(max_sugar+1):
	for j in range(max_sugar):
		#print i,j
		if i*C+D*j<= max_sugar:
			a.add(i*C+D*j)

b=set()
cnt=F/100
for i in range(cnt+1):
	for j in range(cnt+1):
		if A*i*100+B*j*100<=F and A*i*100+B*j*100!=0:
			b.add(A*i*100+B*j*100)

#print a
#print b

noudo=float(E)/(100+E)*100
max_noudo=0
ans=A*100,0

for i in a:
	for j in b:
		t_noudo=float(i)/(i+j)*100
		#print i,j
		if t_noudo <= noudo and t_noudo > max_noudo and i+j<=F:
			#print i,j,t_noudo
			max_noudo=t_noudo
			ans=i+j,i

print ans[0],ans[1]

Submission status: Accepted

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

waters = set()
for wb in range(0,F+1,100*B):
    wa = 0
    while wa + wb <= F:
        waters.add(wa + wb)
        wa += 100*A
waters.remove(0)

sugars = set()
for sd in range(0,F+1,D):
    sc = 0
    while sc + sd <= F:
        sugars.add(sc + sd)
        sc += C

best = -1
best_w = best_s = 0
for w in sorted(waters):
    for s in sorted(sugars):
        if 100*s > w*E: continue
        if w+s > F: continue
        if best < 100*s / (w+s):
            best = 100*s / (w+s)
            best_w = w
            best_s = s

print(best_w+best_s, best_s)

Submission status: Accepted

Solution code:
from math import ceil
A,B,C,D,E,F = map(int,input().split())
W,S = [],[0]
for i in range(ceil(F/A)):
    for j in range(ceil(F/B)):
        w = 100*A*i+100*B*j
        if w <= F and 0 < w and w not in W:
            W.append(w)
for i in range(ceil(F/C)):
    for j in range(ceil(F/D)):
        s = C*i+D*j
        if s <= F and 0 < s and s not in S:
            S.append(s)
Ans1,Ans2,r = 0,0,-1
for wi in W:
    for si in S:
        if r < si/wi and si <= E*(wi//100) and (wi+si) <= F:
            Ans1,Ans2,r = wi+si,si,si/wi
print(Ans1,Ans2)

Submission status: Accepted

Solution code:
from math import ceil, floor


def exist(A, B, x):
    """
    check if i and j exist such that Ai + Bj = x
    """
    max_i = x // A
    for i in range(max_i + 1):
        if (x - A * i) % B == 0:
            return True
    else:
        return False


A, B, C, D, E, F = [int(elem) for elem in input().split(' ')]

max_density = 0.
status_when_max_dens = {'water': 0, 'sugar': 0}
for x in range(1, F + 1):
    if exist(100 * A, 100 * B, x):
        for y in range(F - x + 1):
            if exist(C, D, y):
                density = y / (x + y)
                if (density >= max_density)\
                and (y <= x / 100 * E)\
                and (x + y <= F):
                    max_density = density
                    status_when_max_dens['water'] = x
                    status_when_max_dens['sugar'] = y


water = status_when_max_dens['water']
sugar = status_when_max_dens['sugar']
print(water + sugar, sugar)

Submission status: Accepted

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

for i in range(100*a, f+1, 100):
    b_max = i // (100*b)
    for j in range(0, b_max+1):
        if (i-j*b*100) % (100*a) == 0:
            break
    else:
        continue

    sugar = 0
    for k in range(0, i//100*e+1):
        d_max = k // d
        for l in range(0, d_max+1):
            if (k-d*l) % c == 0:
                if k > sugar and i + k <= f:
                    sugar = k

    if sugar / (i+sugar) * 100 >= con:
        con = sugar / (i+sugar) * 100
        w, s = i, sugar

print("{} {}".format(w+s, s))

Submission status: Accepted

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

for a in range(1+F//100):
    for b in range(1+F//100):
        if 100*(a*A+b*B)<=F:
            M.append(100*(a*A+b*B))
for c in range(F//C):
    for d in range(F//D):
        if c*C+d*D<=F:
            S.append(c*C+d*D)
M = set(M)
S = set(S)

t = -1
ans1 = 0
ans2 = 0
for m in M:
    for s in S:
        if m==s==0:
            pass
        elif s<=E*m//100 and m+s<=F and t<(s*100)/(m+s):
            t = (s*100)/(m+s)
            ans1 = m+s
            ans2 = s

print(ans1, ans2)

Submission status: Accepted

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

for a in range(1+F//100):
    for b in range(1+F//100):
        if 100*(a*A+b*B)<=F:
            M.append(100*(a*A+b*B))

for c in range(1+F//C):
    for d in range(1+F//D):
        if c*C+d*D<=F:
            S.append(c*C+d*D)

ans1 = 0
ans2 = 0
t = -1
for m in M:
    for s in S:
        if m==s==0:
            pass
        elif m+s<=F and s<=E*m//100 and t<(100*s)/(s+m):
            t = (100*s)/(s+m)
            ans1 = m+s
            ans2 = s

print(ans1, ans2)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())#ć­Łč§Ł
w=[]
for i in range(f//100+1):
    for j in range(f//100+1):
        x=100*a*i+100*b*j
        if x<=f:
            w.append(x)
s=[]
for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
max_con=0
ans,ans_2=0,0
for i in w:
    for j in s:
        if i!=0 or j!=0:
            if j<=e*(i//100):
                if i+j<=f:
                    con=(100*j)/(i+j)
                    if max_con<=con:
                        max_con=con
                        ans,ans_2=i+j,j
print(ans,ans_2)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=[]
for i in range(f//100+1):
    for j in range(f//100+1):
        x=100*a*i+100*b*j
        if x<=f:
            w.append(x)
s=[]
for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
max_con=0
ans,ans_2=0,0
for i in w:
    for j in s:
        if i!=0 or j!=0:
            if j<=e*(i//100):
                if i+j<=f:
                    con=(100*j)/(i+j)
                    if max_con<=con:
                        max_con=con
                        ans=i+j
                        ans_2=j
print(ans,ans_2)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=[]
for i in range(f//100+1):
    for j in range(f//100+1):
        x=100*a*i+100*b*j
        if x<=f:
            w.append(x)
s=[]
for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
max_con=0
ans,ans_2=0,0
for i in w:
    for j in s:
        if i==0 and j==0:
            continue
        elif e*(i//100)<j:
            continue
        elif f<i+j:
            continue
        else:
            con=(100*j)/(i+j)
            if max_con<=con:
                max_con=con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
s=[]
for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
w=[]
for i in range(0,f//100+1):
    for j in range(0,f//100+1):
        x=i*a*100+j*b*100
        if x<=f:
            w.append(x)
max_con=0
ans,ans_2=0,0
for i in w:
    for j in s:
        if i==0 and j==0:
            continue
        elif e*(i//100)<j:
            continue
        elif f<i+j:
            continue
        else:
            con=(100*j)/(i+j)
            if max_con<=con:
                max_con=con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
s=[]
for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
w=[]
for i in range(0,f//100+1):
    for j in range(0,f//100+1):
        x=i*a*100+j*b*100
        if x<=f:
            w.append(x)
max_con=0
ans,ans_2=0,0
for i in w:
    for j in s:
        if i==0 and j==0:
            continue
        elif e*(i//100)<j:
            continue
        elif i+j>f:
            continue
        else:
            con=(100*j)/(i+j)
            if max_con<=con:
                max_con=con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
s=[]
for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
w=[]
for i in range(0,f//100+1):
    for j in range(0,f//100+1):
        x=i*a*100+j*b*100
        if x<=f:
            w.append(x)
max_con=0
ans,ans_2=0,0
for x in w:
    for y in s:
        if x==0 and y==0:
            continue
        elif e*(x//100)<y:
            continue
        elif x+y>f:
            continue
        else:
            con=(100*y)/(x+y)
            if max_con<=con:
                max_con=con
                ans=x+y
                ans_2=y
print(ans,ans_2)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
s=[]
for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
w=[]
for i in range(0,f//100+1):
    for j in range(0,f//100+1):
        x=i*a*100+j*b*100
        if x<=f:
            w.append(x)
max_con=0
ans,ans_2=0,0
for x in w:
    for y in s:
        if x==0 and y==0:
            continue
        elif e*(x//100)<y:
            continue
        elif x+y>f:
            continue
        else:
            con=(100*y)/(x+y)
            if max_con<=con:
                max_con=con
                ans=x+y
                ans_2=y
print("{} {}".format(ans,ans_2))

Submission status: Accepted

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

sugar = []
for i in range(f):
    for j in range(f):
        y = i*c + j*d
        if y <= f:
            sugar.append(y)

water = []
for i in range(0, f//100+1):
    for j in range(0, f//100+1):
        x = i*a*100 + j*b*100
        if x <= f:
            water.append(x)
max_concentration = 0
ans1, ans2 = 0, 0
for x in water:
    for y in sugar:
        if x == 0 and y == 0:
            continue
        elif e * (x // 100) < y:
            continue
        elif x + y > f:
            continue
        else:
            concentration = (100 * y) / (x+y)
            if max_concentration <= concentration:
                max_concentration = concentration
                ans1 = x+y
                ans2 = y
print("{} {}".format(ans1, ans2))

Submission status: Accepted

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

W,S = [],[0]

for ai in range(ceil(F/A)):
    for bi in range(ceil(F/B)):
        w = 100*A*ai+100*B*bi
        if w <= F and 0 < w and w not in W:
            W.append(w)
for ci in range(ceil(F/C)):
    for di in range(ceil(F/D)):
        s = C*ci+D*di
        if s <= F and 0 < s and s not in S:
            S.append(s)

AnsWS,AnsS,r = 0,0,-1
for wi in W:
    for si in S:
        if r < si/wi and si <= E*(wi//100) and (wi+si) <= F:
            AnsWS,AnsS,r = wi+si,si,si/wi

print(AnsWS,AnsS)

Submission status: Accepted

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: Accepted

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

sugar = []
for i in range(f):
    for j in range(f):
        y = i*c + j*d
        if y <= f:
            sugar.append(y)

water = []
for i in range(0, f//100+1):
    for j in range(0, f//100+1):
        x = i*a*100 + j*b*100
        if x <= f:
            water.append(x)
max_concentration = 0
ans1, ans2 = 0, 0
for x in water:
    for y in sugar:
        if x == 0 and y == 0:
            continue
        elif e * (x // 100) < y:
            continue
        elif x + y > f:
            continue
        else:
            concentration = (100 * y) / (x+y)
            if max_concentration <= concentration:
                max_concentration = concentration
                ans1 = x+y
                ans2 = y
print("{} {}".format(ans1, ans2))

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f - i + 1, 100 * b):
        if i == 0 and j == 0:
            continue
        y = min((i + j) * e // 100, f - i - j)
        for k in range(0, y + 1, c):
            for l in range(0, y - k + 1, d):
                concentration = 100 * (k + l) / (i + j + k + l)
                if max_concentration <= concentration:
                    max_concentration = concentration
                    res1 = i + j + k + l
                    res2 = k + l
print(str(res1) + ' ' + str(res2))

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
t=100
for i in range(0,f+1,a*100):
    for j in range(0,f-i+1,b*100):
        k=i+j
        if k==0:
            continue
        s=min(f-i-j,(i+j)*e//100)
        for ii in range(0,s+1,c):
            for jj in range(0,s-ii+1,d):
                if t>e-(ii+jj)*100/(i+j):
                    t=e-(ii+jj)*100/(i+j)
                    x,y=ii+jj+i+j,ii+jj
print(str(x)+" "+str(y))

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
concentration_max = 0
tatal_max = 0
sugar_max = 0
for a in range(int(F/100/A)+1):
    rest_F = F - 100*A*a
    for b in range(int(rest_F/100/B)+1):
        sum_water = 100*(A*a+b*B)
        sum_sugar_max = min(sum_water/100*E,F-sum_water)
        for c in range(int(sum_sugar_max/C)+1):
            sum_sugar_max_rest = sum_sugar_max - c*C
            for d in range(int(sum_sugar_max_rest/D)+1):
                #print(a,b,c,d)
                sum_sugar = c*C+d*D
                sum_total = sum_water+sum_sugar
                if sum_total == 0:
                    break
                concentration = sum_sugar/(sum_water+sum_sugar)
                if concentration >= concentration_max:
                    concentration_max = concentration
                    total_max = sum_total
                    sugar_max = sum_sugar
print(total_max,sugar_max)

Submission status: Accepted

Solution code:
a,b,c,d,e,f = map(int,input().split())
x=[]
for i in range(int(f/100+0.9)):
    for j in range(int(f/100+0.9)):
        if (100*a*i+100*b*j)<= f:
            x.append(100*a*i+100*b*j)
y=[]
for i in range(int(f/c+0.9)):
    for j in range(int(f/d+0.9)):
        if (c*i+d*j)<= f:
            y.append(c*i+d*j)
p=e/(100+e)
maxp=0
mj=0
mi=0
for i in x:
    for j in y:
        if((i+j<=f) and (i+j)>0 and (j/(i+j)<=p)):
            if(j/(i+j)>=maxp):
                mj=j
                mi=i
                maxp=j/(i+j)
print(str(mj+mi)+" "+str(mj))

Submission status: Accepted

Solution code:
def c_sugar_water(A, B, C, D, E, F):
    x = set()  # 水の量が取りうるパターン
    y = set()  # 砂糖の量が取りうるパターン
    for i in range(F // 100 + 1):
        for j in range(F // 100 + 1):
            tmp = 100 * A * i + 100 * B * j
            if tmp <= F:
                x.add(tmp)
    for i in range(F):
        for j in range(F):
            tmp = C * i + D * j
            if tmp <= F:
                y.add(tmp)

    concentration = 0  # 砂糖水の濃度
    tmp = [0, 0]
    for water in x:
        for sugar in y:
            if water == 0 and sugar == 0:
                # 水も砂糖も入れないパターン
                continue
            elif E * (water // 100) < sugar:
                # 砂糖を溶かしきれない
                continue
            elif water + sugar > F:
                # ビーカーに入れられる質量を超えた
                continue
            else:
                if (100 * sugar) / (water + sugar) >= concentration:
                    concentration = (100 * sugar) / (water + sugar)
                    tmp = [water + sugar, sugar]
    ans = '{} {}'.format(tmp[0], tmp[1])
    return ans

A,B,C,D,E,F = [int(i) for i in input().split()]
print(c_sugar_water(A, B, C, D, E, F))

Submission status: Accepted

Solution code:
a,b,c,d,e,f = (int(i) for i in input().split())
w,s,num,answer = set(),set(),0,[a*100,0]
for i in range((f-f%(a*100))//(a*100)+1):
	for j in range((f-f%(b*100))//(b*100)+1):
		if i*a*100+j*b*100 <= f:
			w.add(i*a*100+j*b*100)
		else:
			break
smax = int(e*f/((100+e)*1.0))
for i in range((smax-smax%c)//c+1):
	for j in range((smax-smax%d)//d+1):
		if i*c+j*d <= smax:
			s.add(i*c+j*d)
		else:
			break
w2,s2 = sorted(list(w))[::-1],sorted(list(s))[::-1]
for i in w2:
	for j in s2:
		if 0 < i+j <= f and e*i>=100*j and num<(j/((i+j)*1.0)):
			num =  j/((i+j)*1.0)
			answer = [i,j]
print(sum(answer),answer[1])

Submission status: Accepted

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

mizu_arr = []
for i in range(F // (A*100) + 1):
    for j in range((F - i * A * 100) // (B*100) + 1):
        mizu = i * A * 100 + j * B * 100
        if mizu > 0:
            mizu_arr.append(mizu)

mizu_arr = sorted(mizu_arr)

def func(sato):
    min_mizu = sato * 100.0 / E
    max_mizu = F - sato
    for mizu in mizu_arr:
        if max_mizu < mizu:
            return None
        if min_mizu <= mizu:
            return mizu
    return None

max_nodo = 0
ans = [A*100, 0]
max_sato = (F // (100 + E)) * E
for i in range(max_sato // C + 1):
    for j in range((max_sato - i * C) // D + 1):
        sato = i * C + j * D
        mizu = func(sato)
        if not mizu == None:
            if 100 * sato / (mizu + sato) > max_nodo:
                ans = [mizu + sato, sato]
                max_nodo = 100 * sato / (mizu + sato)
              
print("{} {}".format(ans[0], ans[1]))

Submission status: Accepted

Solution code:
a,b,c,d,e,f = map(int,input().split())
sugar = []
for i in range(f//c):
	for k in range(f//d):
		sugartotal = i*c+k*d
		if sugartotal <= f:
			sugar.append([i,k])
n = len(sugar)
ans = []
cans = []
for i in range(n):
	sugartotal = sugar[i][0]*c+sugar[i][1]*d
	watermax = f-sugartotal
	for k in range(watermax//(100*a)+1):
		for p in range(watermax//(100*b)+1):
			if k>0 or p>0:
				watertotal = k*100*a+p*100*b
				if watertotal <= watermax and (watertotal/100)*e>=sugartotal:
					ans.append(sugartotal/(sugartotal+watertotal))
					cans.append([watertotal+sugartotal,sugartotal])

mdensity = max(ans)
ind = ans.index(mdensity)
print(cans[ind][0],cans[ind][1])

Submission status: Accepted

Solution code:
a,b,c,d,e,f = map(int,input().split())
maxden = 0
amax = f //(a*100)
water=a*100
sugar=0
for i in range(amax+1):
  waterA = i*100*a
  res = f-waterA
  bmax = res // (b*100)
  for j in range(bmax+1):
    waterB = j*100*b
    waterS =waterA+waterB
    res = f-waterS
    cmax = res // c
    for k in range(cmax+1):
      sugarC = k*c
      res = f-waterS-sugarC
      dmax = res // d
      for l in range(dmax+1):
        sugarD = l*d
        sugarS = sugarC+sugarD
        if(sugarS+waterS==0):break
        den = (sugarS)*100/(sugarS+waterS)
        #if(den>49 and den<50.1):print(res-sugarD,waterA,waterB,sugarC,sugarD,den)
        #if(sugarS==146 and waterS==200):print(waterS,sugarS,den,(den*(100+e))/100,e)
        #if(sugarS==582 and waterS==800):print(waterS,sugarS,den,(den*(100+e))/100,e)
        if(den>maxden and (den*(100+e)/100)-e<=10**-5):
          maxden = den
          sugar = sugarS
          water = waterS

print(str(water+sugar)+" "+str(sugar))
#print(maxden)

Submission status: Accepted

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

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D

                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar
if c_max ==0:
    sw_max = 100*A
    s_max=0
print(sw_max,s_max)

Submission status: Accepted

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

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D
                
                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if water + sugar <= F and sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar
if c_max ==0:
    sw_max = 100*A
    s_max=0
print(sw_max,s_max)