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:
a,b,c,d,e,f=map(int,input().split())
a100=a*100
b100=b*100
ok=[]
for ai in range(31):
  for bi in range(31):
    for ci in range(101):
      for di in range(101):
        ab= ai*a100+bi*b100
        cd= ci*c+di*d
        if ab + cd >f:
          break
        else:
          if (ab/100)*e>=cd:
            ok.append([ab+cd,cd])
#塩分濃度をキーとしてソートしている
print(*sorted(ok, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
a100=a*100
b100=b*100
ok=[]
for ai in range(31):
  for bi in range(31):
    for ci in range(101):
      for di in range(101):
        ab= ai*a100+bi*b100
        cd= ci*c+di*d
        if ab + cd >f:
          break
        else:
          if (ab/100)*e>=cd:
            ok.append([ab+cd,cd])
print(*sorted(ok, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

Submission status: Accepted

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

ans_water, ans_sugar = 100 * a, 0
for i in range(f // (100 * a) + 1):
  water = 100 * a * i
  if water > f:
    break
  for j in range(((f - water) // (100 * b)) + 1):
    water = 100 * a * i + 100 * b * j
    if water == 0 or water > f:
      break
    for k in range(((f - water) // c) + 1):
      sugar = c * k
      if water + sugar > f or sugar > e * water // 100:
        break
      for l in range(((f - water - sugar) // d) + 1):
        sugar = c * k + d * l
        if water + sugar > f or sugar > e * water // 100:
          break
        if sugar / (water + sugar + 1) > ans_sugar / (ans_water + ans_sugar):
          ans_water, ans_sugar = water, sugar

print(ans_water + ans_sugar, ans_sugar)

Submission status: Accepted

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

syokuen=[0]

if c == 1 or d == 1:
  for i in range(1500+1):
    syokuen.append(i)
else:
  for i in range(1500//a+1):
    for j in range(1500//b+1):
      if c*i+d*j not in syokuen and c*i+d*j <=1500 :
        syokuen.append(c*i+d*j) 

mizu=[0]
for i in range(30):
  for j in range(30):
      if a*i*100 + b*j*100 not in mizu and a*i*100 + b*j*100<=f:
        mizu.append(a*i*100 + b*j*100)
        
noudo_max = 0.0
for i in range(len(syokuen)):
  for j in range(len(mizu)):
    if mizu[j]+syokuen[i] != 0:
      noudo = syokuen[i]/(mizu[j]+syokuen[i])
      if mizu[j]+syokuen[i] <= f and noudo <= e/(100+e) and noudo >= noudo_max:
        noudo_max = noudo
        ans_syokuen = syokuen[i]
        ans_mizu = mizu[j]

print(ans_syokuen+ans_mizu,ans_syokuen)

Submission status: Accepted

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

from itertools import product
w=[]
for i,j in product(range(F//(100*A)+1),range(F//(100*B)+1)):
    if 0<100*A*i+100*B*j<=F:
        w.append(100*A*i+100*B*j)
s=[]
for i,j in product(range(E*F//(100*C)+1),range(E*F//(100*C)+1)):
    if C*i+D*j<=E*(F//100):
        s.append(C*i+D*j)

w.sort()
s.sort()
ans=[]
for a in w:
    for b in s:
        if (a//100)*E>=b and a+b<=F:
            ans.append([a+b,b])
        else:
            break
ans.sort(key=lambda x:x[1]/(x[0]+x[1]),reverse=True)
print(ans[0][0],ans[0][1])

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def concentrate(water, sugar):
    if water+sugar == 0:
        return 0
    else:
        return sugar/(water+sugar)


A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water_list = set()
sugar_list = set()

max_cont = E/(E+100)

max_water = F//B+1
for i in range(max_water):
    remain = F - B*i
    if remain < 0:
        break
    else:
        j = remain//A
        for k in range(j+1):
            # water_list.append(A*k+B*i)
            water_list.add(A*k+B*i)

max_sugar = F//D+1
for i in range(max_sugar):
    tmp = D*i
    remain = F - tmp
    if remain < 0:
        break
    else:
        j = remain//C
        for k in range(j+1):
            # sugar_list.append(D*i+C*k)
            sugar_list.add(D*i+C*k)

#water_list = sorted(set(water_list))
#sugar_list = sorted(set(sugar_list))
water_list = sorted(list(water_list))
sugar_list = sorted(list(sugar_list))

max_tmp = 0
ans = [0, 0]
for water in water_list:
    for sugar in sugar_list:
        if water+sugar > F:
            break
        else:
            conc = concentrate(water, sugar)
            if conc > max_cont:
                break
            else:
                if max_tmp <= conc:
                    max_tmp = conc
                    ans = [water, sugar]
print(sum(ans), ans[1])

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def concentrate(water, sugar):
    if water+sugar == 0:
        return 0
    else:
        return sugar/(water+sugar)


A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water_list = []
sugar_list = []

max_cont = E/(E+100)

max_water = F//B+1
for i in range(max_water):
    remain = F - B*i
    if remain < 0:
        break
    else:
        j = remain//A
        for k in range(j+1):
            water_list.append(A*k+B*i)

max_sugar = F//D+1
for i in range(max_sugar):
    tmp = D*i
    remain = F - tmp
    if remain < 0:
        break
    else:
        j = remain//C
        for k in range(j+1):
            sugar_list.append(D*i+C*k)

water_list = sorted(set(water_list))
sugar_list = sorted(set(sugar_list))

max_tmp = 0
ans = [0, 0]
for water in water_list:
    for sugar in sugar_list:
        if water+sugar > F:
            break
        else:
            conc = concentrate(water, sugar)
            if conc > max_cont:
                break
            else:
                if max_tmp <= conc:
                    max_tmp = conc
                    ans = [water, sugar]
print(sum(ans), ans[1])

Submission status: Accepted

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

W = set([a+b for a in range(0,F+1,100*A) for b in range(0,F+1-a,100*B)])
S = set([c+d for c in range(0,F+1,C) for d in range(0,F+1-c,D)])

ans_con = -1
max_con = E/(100+E)

for w in W:
    for s in S:
        if 0 < s+w <= F and s/(s+w) <= max_con:
            if ans_con < s/(s+w):
                ans_con = s/(s+w)
                ans_sw = s+w
                ans_s = s

print(ans_sw,ans_s)

Submission status: Accepted

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

ans_con = -1
max_con = E/(100+E)*100

a = 0
while F >= 100*A*a:
    b = 0
    while F-100*A*a >= 100*B*b:
        water = 100*(A*a+B*b)
        c = 0
        while F-water >= C*c:
            sugar = C*c+D*max(min(((F-water-C*c)//D),(water*E/100-C*c)//D),0)
            mass = water + sugar
            if 0 < mass <= F:
                con = sugar/mass*100
                if ans_con < con <= max_con:
                    ans_con = con
                    ans_mass = mass
                    ans_sugar = sugar
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

Submission status: Accepted

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

ans_con = -1
max_con = E/(100+E)*100

a = 0
while F >= 100*A*a:
    b = 0
    while F-100*A*a >= 100*B*b:
        water = 100*(A*a+B*b)
        c = 0
        while F-water >= C*c:
            d = 0
            while F-water-C*c >= D*d:
                sugar = C*c+D*d
                mass = water + sugar
                if 0 < mass <= F:
                    con = sugar/mass*100
                    if ans_con < con <= max_con:
                        ans_con = con
                        ans_mass = mass
                        ans_sugar = sugar
                d += 1
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split(" "))
LOOP_A = int(F / (100*A)) + 1
LOOP_B = int(F / (100*B)) + 1
LOOP_C = int((F-100) / C) + 1
LOOP_D = int((F-100) / D) + 1
ans = []
temp = []
for i in range(LOOP_A):
    Ac = i
    for j in range(LOOP_B):
        Bc = j
        W = Ac * A * 100 + Bc * B * 100
        if W >= 100 and W <= F:
            for k in range(LOOP_C):
                Cc = k
                if W + (Cc * C) <= F:
                    for l in range(LOOP_D):
                        Dc = l
                        S = Cc * C + Dc * D
                        total = W + S 
                        SW = S / W
                        #print(Dc)
                        if F >= total and SW <= E/100:
                            ans.append(str(total) + " " + str(S))
                            temp.append(S / total)
print(ans[temp.index(max(temp))])

Submission status: Accepted

Solution code:
from itertools import product
a, b, c, d, e, f = map(int, input().split())
A = sorted(list(set(filter(lambda x: 100*x <= f and x,
           [i*a+j*b for i, j in product(range(31), range(16))]))))
B = [min(x*e, f-100*x) for x in A]

C = []
for i in range(len(A)):
    m = 0
    for k in range(29):
        if k*d <= B[i]:
            m = max(m, k*d+(B[i]-k*d)//c*c)
    C.append(m)

Table = [100*a, 0]
for x, y in zip(A, C):
    if y/(100*x+y) > Table[1]/Table[0]:
        Table = [100*x+y, y]
print(Table[0], Table[1])

Submission status: Accepted

Solution code:
def solve(A, B, C, D, E, F):
    sugers = set()
    for i in range(0, F // C + 1):
        for j in range(0, F // D + 1):
            s = (C * i + D * j)
            if s + 100 * s / E <= F:
                sugers.add(C * i + D * j)
            else:
                break
    sugers = sorted(list(sugers))

    waters = set()
    for i in range(0, F // A + 1):
        for j in range(0, F // B + 1):
            if (A * i + B * j) * 100 <= F:
                waters.add(A * i + B * j)
            else:
                break
    waters = sorted(list(waters))

    dense, w_all, w_suger = 0, A * 100, 0
    for s in sugers:
        for w in waters:
            if s + 100 * w <= F and s <= w * E and w + s > 0:
                densei = 100 * s / (100 * w + s)
                if dense < densei:
                    dense = densei
                    w_all = s + 100 * w
                    w_suger = s
                    break
    return " ".join([str(w_all), str(w_suger)])


if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split(" "))
    print(solve(A, B, C, D, E, F))

Submission status: Accepted

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

ma = 0
for aa in range(0, f+1, a * 100):
    for bb in range(0, f - aa + 1, b * 100):
        water = aa + bb
        if water == 0:
            continue
        smax = min(water // 100 * e, f - water)
        for cc in range(0, smax + 1, c):
            dd = (smax - cc) // d * d
            sugar = cc + dd
            ratio = 100 * sugar / float(water + sugar)
            if ratio >= ma:
                ma = ratio
                ans = [water + sugar, sugar]

print(*ans)

Submission status: Accepted

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

W = set()
for a in range(0, F+1, 100*A):
    for b in range(0, F+1-a, 100*B):
        W.add(a+b)

S = set()
for c in range(0, F+1, C):
    for d in range(0, F+1-c, D):
        S.add(c+d)

rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= (E/100)*w:
            if s/(w+s) > rate:
                rate = s/(w+s)
                ans = w+s, s
                
print(ans[0], ans[1])

Submission status: Accepted

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

W = set()
for a in range(0, F+1, 100*A):
    for b in range(0, F+1-a, 100*B):
        W.add(a+b)

S = set()
for c in range(0, F+1, C):
    for d in range(0, F+1-c, D):
        S.add(c+d)

rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= w*E//100:
            if s/(w+s) > rate:
                rate = s/(w+s)
                ans = w+s, s
                
print(ans[0], ans[1])

Submission status: Accepted

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

def res(water, sugar, memo):
    if water + sugar > F:
        return None
    if (water, sugar) in memo:
        return None
    if water + sugar == 0:
        memo[(water, sugar)] = -1        
    elif E*(water+sugar) >= sugar*(100+E):
        memo[(water, sugar)] = sugar/(water+sugar)
    else:
        memo[(water, sugar)] = -1

    res(water+100*A, sugar, memo)
    res(water+100*B, sugar, memo)
    res(water, sugar+C, memo)
    res(water, sugar+D, memo)
    return memo

memo = res(0, 0, {})
k, v = max(memo.items(), key=lambda x:x[1])
print(k[0]+k[1], k[1])

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginner_Contest074-C
#  TODO https://atcoder.jp/contests/abc074/tasks/arc083_a

def solveProblem(WaterOne100,WaterTwo100,SugarOne,SugarTwo,meltMax,maxSugarWater):
	maxBreakDown = meltMax / (meltMax + 100)
	WaterOneCup = WaterOne100 * 100
	WaterTwoCup = WaterTwo100 * 100
	WaterPossibleList=[]
	for oneCup in range(0,maxSugarWater+1,+WaterOneCup):
		for twoCup in range(0,maxSugarWater-oneCup+1,+WaterTwoCup):
				WaterPossibleList.append(oneCup+twoCup)

	SugarPossibleList = []
	for oneSugarCup in range(0,maxSugarWater+1,+SugarOne):
		for twoSugarCup in range(0,maxSugarWater+1-oneSugarCup,+SugarTwo):
				SugarPossibleList.append(oneSugarCup+twoSugarCup)

	returnSugarWater = -1
	returnSugar = -1
	limitedMaxDensity = -1
	for water in WaterPossibleList:
		for sugar in SugarPossibleList:
			if (0 < water+sugar) and (water+sugar<=maxSugarWater) and ((sugar/(sugar+water)) <= maxBreakDown):
				if limitedMaxDensity <= sugar/(sugar+water):
					limitedMaxDensity = sugar/(sugar+water)
					returnSugarWater = water+sugar
					returnSugar = sugar

	answer = returnSugarWater,returnSugar
	return answer

if __name__ == '__main__':
	A,B,C,D,E,F = map(int,input().strip().split(' '))
	solWater,solSuger = solveProblem(A,B,C,D,E,F)
	print("{} {}".format(solWater,solSuger))

Submission status: Accepted

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

W = set()
for a in range(0, F+1, A*100):
    for b in range(0, F+1-a, B*100):
        W.add(a+b)

S = set()
for c in range(0, F+1, C):
    for d in range(0, F+1-c, D):
        S.add(c+d)

rate = -1
for w in W:
    for s in S:
        if 0 < w+s <= F and s <= w*E // 100:
            if s/(w+s) > rate:
                rate = s/(w+s)
                ans = w+s, s
                
print(ans[0], ans[1])

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F//100+1)]
dp[0][0] = True
for i in range(F//100+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if j >= C:
            dp[i][j] = dp[i][j] or dp[i][j-C]
        if j >= D:
            dp[i][j] = dp[i][j] or dp[i][j-D]
        if i >= A:
            dp[i][j] = dp[i][j] or dp[i-A][j]
        if i >= B:
            dp[i][j] = dp[i][j] or dp[i-B][j]

dense = -1
argi, argj = 0, 0
for i in range(F//100+1):
    for j in range(F+1):
        if i == j == 0:
            continue
        if dp[i][j]:
            if j/(100*i+j) >= dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)

Submission status: Accepted

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

def calcCons(nA, nB, nC, nD):
    W = nA*a*100 + nB*b*100
    S = nC*c + nD*d
    if W+S == 0:
        return -1
    return 100*S/(W+S)


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


maxCons = 0
answer_W, answer_S = 0, 0

nA, nB, nC, nD = 0, 0, 0, 0
while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
    # Operation A
    while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
        # Operation B
        while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
            # Operation C
            while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
                # Operation D
                cons = calcCons(nA, nB, nC, nD)
                # print("{} {} {} {} {}".format(cons, nA, nB, nC, nD))
                if cons > maxCons and cons <= 100*e/(100+e):
                    maxCons = cons
                    answer_W, answer_S = nA*a*100 + nB*b*100, nC*c + nD*d
                nD += 1
            nD = 0
            nC += 1
        nC = 0
        nB += 1
    nB = 0
    nA += 1

if maxCons == 0:
    answer_W = a*100
print("{} {}".format(int(answer_W+answer_S), int(answer_S)))

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def dense(a, b):
    try:
        return 100 * b / (a + b)
    except ZeroDivisionError:
        return 0


A, B, C, D, E, F = il()
A *= 100
B *= 100
max_dense = 0
max_water = 0
max_sugar = 0
for a in range(31):
    for b in range(31):
        water = a * A + b * B
        if water == 0:
            break
        for c in range((F - water) // C + 1):
            for d in range((F - water) // D + 1):
                sugar = c * C + d * D
                if water + sugar > F or water / 100 * E < sugar:
                    break
                if max_dense <= dense(water, sugar):
                    max_dense = dense(water, sugar)
                    max_water = water
                    max_sugar = sugar
print(max_water + max_sugar, max_sugar)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
limwater = F // 100
waterdp = [False] * (limwater + 1)
waterdp[0] = True
for i in range(1, limwater + 1):
	if i >= A and waterdp[i - A]:
		waterdp[i] = True
	if i >= B and waterdp[i - B]:
		waterdp[i] = True
sugardp = [False] * (F + 1)
sugardp[0] = True
for i in range(1, F + 1):
	if i >= C and sugardp[i - C]:
		sugardp[i] = True
	if i >= D and sugardp[i - D]:
		sugardp[i] = True
waterans = 0
sugarans = 0
maxdensity = -1.0
for i in range(1, limwater + 1):
	for j in range(0, F + 1):
		if waterdp[i] and sugardp[j] and i * 100 + j <= F:
			density = j / (i * 100 + j)
			if density <= E / (100 + E) and density > maxdensity:
				maxdensity = density
				waterans = i
				sugarans = j
print(waterans * 100 + sugarans, sugarans)

Submission status: Accepted

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

water = []
for a in range(31):
    for b in range(31):
        if 100 * a * A + 100* b * B <= F:
            water.append(100 * a * A + 100 * b * B)
water = list(set(water))
water.remove(0)

sugar = []

for c in range(3001):
    for d in range(3001):
        if c * C + d * D <= F:
            sugar.append(c * C + d * D)
sugar = list(set(sugar))
sugar.remove(0)

memo = []
for w in water:
    for s in sugar:
        if w + s <= F and s/(w+s) <= E/(100+E):
            memo.append([s/(s+w),w+s, s])
memo.sort(reverse=True)
if len(memo) == 0:
    print(100 * A, 0)
else:
    print(memo[0][1], memo[0][2])

Submission status: Accepted

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

ans=0
Wit=A*100
Cnc=0

for a in range(30):
    if a*A>30:
        break
    for b in range(31):
        if b*B>30:
            break
        for c in range(3000):
            if a*A*100+b*B*100+c*C>F:
                break
            for d in range(3000):
                if 0<a*A*100+b*B*100+c*C+d*D>F:
                    break
                else:
                    if a==0 and b==0:
                        pass
                    else:
                        if (c*C*100+d*D*100)<=E*(a*A*100+b*B*100):
                            if ans<((c*C*100+d*D*100)/(a*A*100+b*B*100)):
                                ans=((c*C*100+d*D*100)/(a*A*100+b*B*100))
                                Wit=(a*A*100+b*B*100+c*C+d*D)
                                Cnc=(c*C+d*D)
                  #print(c,d)
print(Wit,Cnc)

Submission status: Accepted

Solution code:
def abc074_c():
    from math import ceil
    a, b, c, d, e, f = map(int, input().split())
    ans_wat = 100 * a
    ans_sug = 0

    for i in range(ceil(f / (100 * a))):
        for j in range(ceil((f - 100 * a * i) / (100 * b))):
            for k in range((f - 100 * (a * i + b * j)) // c + 1):
                for l in range((f - 100 * (a * i + b * j) - c * k) // d + 1):
                    tmp_sug = c * k + d * l
                    tmp_wat = 100 * (a * i + b * j)
                    if tmp_wat and tmp_sug / tmp_wat <= e / 100 and \
                            tmp_sug / (tmp_wat + tmp_sug) > ans_sug / (ans_wat + ans_sug):
                        ans_sug = c * k + d * l
                        ans_wat = 100 * (a * i + b * j)
    print(ans_wat + ans_sug, ans_sug)


abc074_c()

Submission status: Accepted

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

waterlist=[]
for i in range(0,int(f/100/a)+1):
  for j in range(0,int(f/100/b)+1):
    if 100*a*i+100*b*j <=f:
      waterlist+=[100*a*i+100*b*j]
waterlist=list(set(waterlist))
#print(x)

sugarlist=[]
for i in range(int(f/c)+1):
  for j in range(int(f/d)+1):
    if c*i+d*j <=f:
      sugarlist+=[c*i+d*j]
sugarlist=list(set(sugarlist))
#print(y)

density=0

for i in range(len(waterlist)):
  for j in range(len(sugarlist)):
    if 0 < waterlist[i]+sugarlist[j] <= f and sugarlist[j]<=waterlist[i]/100*e:
      tmp=sugarlist[j]/(waterlist[i]+sugarlist[j])
      if density <= tmp:
        density = tmp
        ans1=waterlist[i]+sugarlist[j]
        ans2=sugarlist[j]
        
print(ans1,ans2)

Submission status: Accepted

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

waterlist=[]
for i in range(0,f+100*a,100*a):
  for j in range(0,f+100*b,100*b):
    if i+j <=f:
      waterlist+=[i+j]
waterlist=list(set(waterlist))
#print(x)

sugarlist=[]
for i in range(int(f/c)+1):
  for j in range(int(f/d)+1):
    if c*i+d*j <=f:
      sugarlist+=[c*i+d*j]
sugarlist=list(set(sugarlist))
#print(y)

density=0

for i in range(len(waterlist)):
  for j in range(len(sugarlist)):
    if 0 < waterlist[i]+sugarlist[j] <= f and sugarlist[j]<=waterlist[i]/100*e:
      tmp=sugarlist[j]/(waterlist[i]+sugarlist[j])
      if density <= tmp:
        density = tmp
        ans1=waterlist[i]+sugarlist[j]
        ans2=sugarlist[j]
        
print(ans1,ans2)

Submission status: Accepted

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

sugerWater = 0
suger = 0
maxConcentration = 0.0
for a in range(31):
    for b in range(16):
        for c in range(3001):
            for d in range(1501):
                x = a * 100 * A + b * 100 * B
                y = c * C + d * D
                if 0 < x + y <= F and 100 * y <= E * x:
                    concentration = 100 * y / (x + y)
                    if maxConcentration <= concentration:
                        maxConcentration = concentration
                        sugerWater = x + y
                        suger = y
                else:
                    break

print('{} {}'.format(sugerWater, suger))

Submission status: Accepted

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

    ws = set()
    for w_a in range(0, f + 1, 100 * a):
        for w_b in range(0, f + 1 - w_a, 100 * b):
            ws.add(w_a + w_b)
    ws.remove(0)

    ss = set()
    for s_c in range(0, f + 1, c):
        for s_d in range(0, f + 1 - s_c, d):
            ss.add(s_c + s_d)
    ss.remove(0)

    ws = sorted(iter(ws))
    ss = sorted(iter(ss))

    res = (100 * a, 0)
    density_max = 0

    for w in ws:
        for s in ss:
            if w + s > f:
                break
            if w * e < s * 100:
                break
            density = s / (w + s)
            if density > density_max:
                density_max = density
                res = (w + s, s)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

water_cand = []
for i in range(F):
    for j in range(F):
        tmp = 100 * A * i + 100 * B * j
        if tmp > F:
            break
        water_cand.append(tmp)

ws_cand = []
for x in water_cand:
    for i in range(F-x+1):
        for j in range(F-x+1):
            tmp = C * i + D * j
            if x + tmp > F:
                break
            if x + tmp == 0:
                ws_cand.append((x, tmp))
                continue
            if (tmp / (x+tmp)) <= (E / (100+E)):
                ws_cand.append((x, tmp))
if len(ws_cand) == 1 and ws_cand[0] == (0, 0):
    print(0, 0)
    exit()
ws_cand.remove((0, 0))
ans = max(ws_cand, key=lambda x: x[1] / (x[0]+x[1]))
print(ans[0]+ans[1], ans[1])

Submission status: Accepted

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

water_cand = []
for i in range(F):
    for j in range(F):
        tmp = 100 * A * i + 100 * B * j
        if tmp > F:
            break
        water_cand.append(tmp)

ws_cand = []
for x in water_cand:
    for i in range(F-x+1):
        for j in range(F-x+1):
            tmp = C * i + D * j
            if x + tmp == 0:
                ws_cand.append((x, tmp))
                continue
            if x + tmp <= F and (tmp / (x+tmp)) <= (E / (100+E)):
                ws_cand.append((x, tmp))
            elif x + tmp > F:
                break
if len(ws_cand) == 1 and ws_cand[0] == (0, 0):
    print(0, 0)
    exit()
ws_cand.remove((0, 0))
ans = max(ws_cand, key=lambda x: x[1] / (x[0]+x[1]))
print(ans[0]+ans[1], ans[1])

Submission status: Accepted

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

W = set()
for a in range(0,F+1,100*A) :
    for b in range(0, F-a+1,100*B) :
        water = a+b
        W.add(water)
W.remove(0)

S = set()
for c in range(0,F+1,C) :
    for d in range(0,F-c+1,D) :
        sugar = c+d
        S.add(sugar)

ans_water = -1
ans_sugar = -1
ans_sugar_water = -1
ans_density = -1

W = sorted(list(W))
S = sorted(list(S))

for i in W :
    for j in S :
        if (i+j) > F :
            break
        if i*E < j*100 :
            break
        density = (j/(i+j))
        if density > ans_density :
            ans_density = density
            ans_water = i
            ans_sugar = j
            ans_sugar_water = ans_water + ans_sugar
print(ans_sugar_water, ans_sugar)

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
maxcon = 0
wans = 0
sans = 0
for i in range(f//(a*100) + 1):
    for j in range((f-i*100*a)//(b*100) + 1):
        for k in range((f-i*100*a-j*100*b)//c + 1):
            for l in range((f-i*100*a-j*100*b-k*c)//d + 1):
                if i+j+k+l != 0 and (k*c+l*d)*(100+e) <= e*(100*(i*a+j*b)+k*c+l*d):
                    con = 100*(k*c+l*d) / (100*(i*a+j*b)+k*c+l*d)
                    maxcon = max(maxcon, con)
                    if con == maxcon:
                        wans = 100*(i*a+j*b)
                        sans = k*c+l*d
print(wans+sans, sans)

Submission status: Accepted

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

# 900
water = set()
for a in range(F//(100*A)+1):
	for b in range(F//(100*B)+1):
		w = A*a + B*b
		if w > F//100:
			break
		water.add(w)
water.remove(0)

suger = set()
for c in range(F//C+1):
	for d in range(F//D+1):
		s = C*c + D*d
		if s > F:
			break
		suger.add(s)

# print(water, suger)

max_num = 0
max_w, max_s = A, 0
for w in water:
	for s in suger:
		if 100*w+s > F or s > E*w:
			continue
		# print(w*100, s)
		if max_num < s/w:
			max_num = s/w
			max_w, max_s = w, s

print(100*max_w+max_s, max_s)

Submission status: Accepted

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

n = f//(100*a)
m = f//(100*b)
p = f//c
q = f//d

mx = 0
for i in range(n+1):
    for j in range(m+1):
        for k in range(p+1):
            for l in range(q+1):
                if i == 0 and j == 0:
                    continue
                s = 100*a*i+100*b*j
                t = c*k+d*l
                u = 100*t/s
                if s + t> f:
                    continue
                if u > e:
                    continue
                if mx <= u:
                    mx = u
                    ans1, ans2 = s+t, t
                    if mx == e:
                        print(ans1, ans2)
                        exit()
print(ans1, ans2)

Submission status: Accepted

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

n = f//(100*a)
m = f//(100*b)
p = f//c
q = f//d

mx = 0
for k in range(p+1):
    for l in range(q+1):
        for i in range(n+1):
            for j in range(m+1):
                if i == 0 and j == 0:
                    continue
                s = 100*a*i+100*b*j
                t = c*k+d*l
                u = 100*t/s
                if s + t> f:
                    continue
                if u > e:
                    continue
                if mx <= u:
                    mx = u
                    ans1, ans2 = s+t, t
                    if mx == e:
                        print(ans1, ans2)
                        exit()
print(ans1, ans2)