Problem:


Score : 300 points

Problem Statement

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

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

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

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

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

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

Snuke will make sugar water with the highest possible density.

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

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

Constraints

1 \leq A < B \leq 30

1 \leq C < D \leq 30

1 \leq E \leq 100

100A \leq F \leq 3 000

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

Inputs

Input is given from Standard Input in the following format:

A B C D E F

Outputs

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

Sample Input 1

1 2 10 20 15 200

Sample Output 1

110 10

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

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

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

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

Sample Input 2

1 2 1 2 100 1000

Sample Output 2

200 100

There are other acceptable outputs, such as:

400 200

However, the output below is not acceptable:

300 150

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

Sample Input 3

17 19 22 26 55 2802

Sample Output 3

2634 934



Sample input:
1 2 10 20 15 200


Sample output:
110 10

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = list(map(int, input().split()))
num_A = int(F / A / 100) + 1
num_B = int(F / B / 100) + 1
def opt_s(x, y, S):
    num_x = int(S / x) + 1
    num_y = int(S / y) + 1
    count = 0
    for p in range(num_x):
        for q in range(num_y):
            if x * p + y * q > S:
                break
            else:
                count = max(count, x * p + y * q)
    return count
sugar = 0
water = 100
for i in range(num_A):
    for j in range(num_B):
        if i * A * 100 + j * B * 100 > F:
            break
        else:
            S_max = min(F - i * A * 100 - j * B * 100, E * (i * A + j * B))
            result = opt_s(C, D, S_max)
            if  result > sugar:
                sugar = result
                water = (i * A + j * B) * 100 + sugar
print(water, sugar)

Submission status: Wrong Answer

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

ab_list = set()

for i in range(0,f//100+1,a):
    for j in range(0, f//100-i+1, b):
        ab_list.add(100*(i+j))

ab_max = max(ab_list)

sug_max = int(ab_max*(e/100))

cd_list = set()

for i in range(0,sug_max+1, c):
    for j in range(0, sug_max-i+1, d):
        cd_list.add(i+j)

water = list(ab_list)
water.sort()

sugar = list(cd_list)
sugar.sort()

max_noudo = 0
ans = [0,0]
for w in water:
    for s in sugar:
        if w==0 and s==0:
            continue
        if 100*s <= e*w and w+s <= f:
            noudo = s/(w+s)
            if noudo > max_noudo:
                max_noudo = noudo
                ans = [w+s, s]
                
print(*ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

A,B,C,D,E,F = inpl()
water = set()
suger = set()

aa = A*100
while aa <= F:
	tmp = aa
	water.add(tmp)
	while tmp <= F:
		tmp += B*100
		water.add(tmp)
	aa += A*100


aa = C
MAX = F*E/100*5
while aa <= MAX:
	tmp = aa
	suger.add(tmp)
	while tmp <= MAX:
		suger.add(tmp)
		tmp += D
	aa += C

ans = 0
anss = [0,0]
MAXper = E/(100+E)*100
for w in water:
	for s in suger:
		per = s/(s+w)*100
		if s+w <= F and ans < per <= MAXper:
			ans = per
			anss = [w+s,s]

print (' '.join(map(str,anss)))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

A,B,C,D,E,F = inpl()
water = set()
suger = set()

aa = A*100
while aa <= F:
	tmp = aa
	while tmp <= F:
		water.add(tmp)
		tmp += B*100
	aa += A*100


aa = C
MAX = F*E/100
while aa <= MAX:
	tmp = aa
	while tmp <= MAX:
		suger.add(tmp)
		tmp += D
	aa += C

ans = 0
anss = [0,0]
MAXper = E/(100+E)*100
for w in water:
	for s in suger:
		per = s/(s+w)*100
		if s+w <= F and ans < per <= MAXper:
			ans = per
			anss = [w+s,s]

print (' '.join(map(str,anss)))

Submission status: Wrong Answer

Solution code:
import itertools
a,b,c,d,e,f = [int(_) for _ in input().split()]

water = []
i = 0
while True:
    j = 0
    if i * 100 * a + j * 100 * b > f:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * 100 * a + j * 100 * b > f:
            break
        water.append(i * 100 * a + j * 100 * b)
        j += 1
    i += 1
set_water = sorted(set(water))

sugar = []
i = 0
while True:
    j = 0
    if i * c + j * d > f * e // 100:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * c + j * d > f * e // 100:
            break
        sugar.append(i * c + j * d)
        j += 1
    i += 1
set_sugar = sorted(set(sugar))

most_dense = 0
final_total = 0
final_sugar = 0
for i, j in itertools.product(range(0,len(set_water)), range(0, len(set_sugar))):
    density = set_sugar[j] / (set_water[i] + set_sugar[j])
    if density > most_dense and set_water[i] * e // 100 >= set_sugar[j] and set_water[i] + set_sugar[j] < f:
        most_dense = density
        final_total = set_water[i]+set_sugar[j]
        final_sugar = set_sugar[j]

if final_total == 0:
    final_total = a * 100
print(final_total, final_sugar)

Submission status: Wrong Answer

Solution code:
import itertools
a,b,c,d,e,f = [int(_) for _ in input().split()]

water = []
i = 0
while True:
    j = 0
    if i * 100 * a + j * 100 * b > f:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * 100 * a + j * 100 * b > f:
            break
        water.append(i * 100 * a + j * 100 * b)
        j += 1
    i += 1
set_water = sorted(set(water))

sugar = []
i = 0
while True:
    j = 0
    if i * c + j * d > f * e // 100:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * c + j * d > f * e // 100:
            break
        sugar.append(i * c + j * d)
        j += 1
    i += 1
set_sugar = sorted(set(sugar))

most_dense = 0
final_total = 0
final_sugar = 0
for i, j in itertools.product(range(0,len(set_water)), range(0, len(set_sugar))):
    density = set_sugar[j] / (set_water[i] + set_sugar[j])
    if density > most_dense and set_water[i] * e // 100 >= set_sugar[j] and set_water[i] + set_sugar[j] < f:
        most_dense = density
        final_total = set_water[i]+set_sugar[j]
        final_sugar = set_sugar[j]

print(final_total, final_sugar)

Submission status: Wrong Answer

Solution code:
import itertools
a,b,c,d,e,f = [int(_) for _ in input().split()]

water = []
i = 0
while True:
    j = 0
    if i * 100 * a + j * 100 * b > f:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * 100 * a + j * 100 * b > f:
            break
        water.append(i * 100 * a + j * 100 * b)
        j += 1
    i += 1

sugar = []
i = 0
while True:
    j = 0
    if i * c + j * d > f * e // 100:
        break
    while True:
        if i == 0 and j == 0:
            j += 1
            continue
        if i * c + j * d > f * e // 100:
            break
        sugar.append(i * c + j * d)
        j += 1
    i += 1

most_dense = 0
final_total = 0
final_sugar = 0
for i, j in itertools.product(range(0,len(water)), range(0, len(sugar))):
    density = sugar[j] / (water[i] + sugar[j])
    if water[i] + sugar[j] < f and water[i] * e // 100 >= sugar[j] and density >= most_dense:
        most_dense = density
        final_total = water[i]+sugar[j]
        final_sugar = sugar[j]

print(final_total, final_sugar)

Submission status: Wrong Answer

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

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

    ans_list = []

    for i in range(31):
        for j in range(31):
            for k in range(31):
                for l in range(31):
                    water = 100 * a * i + 100 * b * j
                    sugar = c * k + d * l
                    if water + sugar <= f and water > 0:
                        consentration = (100 * sugar) / (water + sugar)
                        if consentration <= (100 * e) / (100 + e):
                            ans_list.append([consentration, water, sugar])
    ans_list.sort(key=lambda x:x[0])
    print(ans_list[-1][1] + ans_list[-1][2], ans_list[-1][2])

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map( int, input().split())
ans = 0
ansL = 0
ansM = 0
for i in range(30//a+1):
    for j in range((30-i)//b+1):
        L = a*i + b*j
        M = 0
        for k in range(f):
            if 100*L + k*c <= f and k*c <= L*e:
                m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d)
                M = max(M, m+k*c)
        if M+L != 0 and 100*L + M <= f and M <= L*e:
            if (M*100)/(M+L*100) > ans:
                ans = (M*100)/(M+L*100)
                ansL = L*100
                ansM = M
if ansL == 0:
    print(a*100)
else:
    print('{} {}'.format(ansL+ansM,ansM))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map( int, input().split())
ans = 0
ansL = 0
ansM = 0
for i in range(30//a+1):
    for j in range((30-i)//b+1):
        L = a*i + b*j
        M = 0
        for k in range(f):
            if 100*L + k*c <= f:
                m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d)
                M = max(M, m+k*c)
        if M+L != 0 and 100*L + M <= f and M <= L*e:
            if (M*100)/(M+L*100) > ans:
                ans = (M*100)/(M+L*100)
                ansL = L*100
                ansM = M
if L == 0:
    print(a*100)
else:
    print('{} {}'.format(ansL+ansM,ansM))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map( int, input().split())
ans = 0
ansL = 0
ansM = 0
for i in range(30//a+1):
    for j in range((30-i)//b+1):
        L = a*i + b*j
        M = 0
        for k in range(f):
            if 100*L + k*c <= f:
                m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d)
                M = max(M, m+k*c)
        if M+L != 0 and 100*L + M <= f and M <= L*e:
            if (M*100)/(M+L*100) > ans:
                ans = (M*100)/(M+L*100)
                ansL = L*100
                ansM = M
print('{} {}'.format(ansL+ansM,ansM))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map( int, input().split())
ans = 0
ansL = 0
ansM = 0
for i in range(30//a+1):
    for j in range((30-i)//b+1):
        L = a*i + b*j
        M = 0
        for k in range(f):
            if 100*L + k*c <= f:
                m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d)
                M = max(M, m+k*c)
        if M+L != 0 and 100*L + M <= f:
            if (M*100)/(M+L*100) > ans:
                ans = (M*100)/(M+L*100)
                ansL = L*100
                ansM = M
print('{} {}'.format(ansL+ansM,ansM))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map( int, input().split())
ans = 0
ansL = 0
ansM = 0
for i in range(30//a+1):
    for j in range((30-i)//b+1):
        L = a*i + b*j
        M = 0
        for k in range(f):
            if 100*L + k*c <= f:
                m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d)
                M = max(M, m+k*c)
        if M+L != 0 and 100*L + M <= f:
            if (M*100)/(M+L*100) > ans:
                ansL = L*100
                ansM = M
print('{} {}'.format(ansL+ansM,ansM))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map( int, input().split())
ans = 0
ansL = 0
ansM = 0
for i in range(30//a+1):
    for j in range((30-i)//b+1):
        L = a*i + b*j
        M = 0
        for k in range(f):
            if 100*L + k*c <= f:
                m = min(((e*L-k*c)//d)*d, ((f-100*L-k*c)//d)*d)
                M = max(M, m+k*c)
        if M+L != 0 and 100*L + M <= f:
            if (M*100)/(M+L*100) > ans:
                ansL = L*100
                ansM = M
print('{} {}'.format(ansL,ansM))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
m=min(A,B)*100
l=[]
for i in range(1,1+F//m):
  d=F-m*i
  for j in range(1+d//C):
    for k in range(1+d//D):
      if d>=C*j+D*k:
        if (C*j+D*k)/m*100<=E:
          l.extend([(m*i,C*j+D*k)])
l=sorted(l,key=lambda x:x[1]/x[0])[::-1]
print(l[0][0]+l[0][1],l[0][1])

Submission status: Wrong Answer

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

import functools
import sys
sys.setrecursionlimit(10**5)

@functools.lru_cache(maxsize=None)
def calc_strength(sugar, water):
    if water == 0: return -1
    return sugar * 100 / (sugar + water)

@functools.lru_cache(maxsize=None)
def f(strength, sugar, water):
    cand = []
    for x in ((C, 0), (D, 0), (0, 100*A), (0, 100*B)):
        s, w = sugar + x[0], water + x[1]
        if s + w <= F and s * 100 <= w * E:
            cand.append(f(calc_strength(s, w), s, w))
    if cand: return sorted(cand, reverse=True)[0]
    return (strength, sugar + water, sugar)
    
print(*f(-1, 0, 0)[1:])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

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


def f(x, y):
    max_i = F // x
    max_j = F // y
    arr = []
    for i in range(max_i + 1):
        for j in range(max_j + 1):
            a = x * i + y * j
            if a <= F:
                arr.append(a)
    return sorted(list(set(arr)))


water = f(100 * A, 100 * B)
sugar = f(C, D)

ans = []
for w in water:
    if w == 0:
        continue
    for s in sugar:
        if w + s <= F and s / w * 100 <= E:
            ans.append((w + s, s, s / (w + s)))
ans = sorted(ans, key=itemgetter(2), reverse=True)
print(ans[0][0], ans[0][1])

Submission status: Wrong Answer

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


def f(x, y):
    max_i = F // x
    max_j = F // y
    arr = []
    for i in range(max_i + 1):
        for j in range(max_j + 1):
            a = x * i + y * j
            if a < F:
                arr.append(a)
    return sorted(list(set(arr)))


water = f(100 * A, 100 * B)
sugar = f(C, D)

ans = [(0, 0, 0)]
for w in water:
    if w == 0:
        continue
    for s in sugar:
        if w + s <= F and s / w * 100 <= E:
            ans.append((w + s, s, s / (w + s)))
ans = sorted(ans, key=lambda x: x[2], reverse=True)
print(ans[0][0], ans[0][1])

Submission status: Wrong Answer

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

maximum = 0
max_water = 0
max_sugar = 0

queue = [[a, 0], [b, 0]]

visited = set()

while queue:
    now = queue.pop(0)
    now = tuple(now)

    if now in visited:
        continue

    visited.add(now)

    water, sugar = now

    if water * 100 + sugar > f:
        continue

    if (sugar / water) <= e:
        if maximum < sugar / (water*100):
            maximum = sugar / (water * 100)
            max_water = water
            max_sugar = sugar
    queue.append([water+a, sugar])
    queue.append([water+b, sugar])
    queue.append([water, sugar+c])
    queue.append([water, sugar+d])

print(max_water*100 + max_sugar, max_sugar)

Submission status: Wrong Answer

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

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

water = []
for i in range(0, F+1, A*100):
    for j in range(0, F+1, B*100):
        if i + j <= F:
            water.append(i + j)
water = sorted(list(set(water)), reverse=True)
# 0はあとで割る時に困るので外す
water.pop(len(water)-1)

suger = []
for i in range(0, F+1, C):
    for j in range(0, F+1, D):
        if i + j <= F:
            suger.append(i + j)
suger = sorted(list(set(suger)))

ans_ws = 0
ans_s = 0
node = 0
# 水は多い方、砂糖は少ない方から見ていく
for i in range(len(water)):
    for j in range(len(suger)):
        # 合計量チェック
        if water[i] + suger[j] > F:
            break
        # 溶ける量チェック
        if suger[j] / (water[i] + suger[j]) <= E / (E + 100):
            # 最大濃度更新なら答えを更新
            if suger[j] / (water[i] + suger[j]) > node:
                node = suger[j] / (water[i] + suger[j])
                ans_ws = water[i] + suger[j]
                ans_s = suger[j]
print(str(ans_ws) + " " + str(ans_s))

Submission status: Wrong Answer

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

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

water = []
for i in range(A*100, F+1, A*100):
    water.append(i)
for i in range(B*100, F+1, B*100):
    water.append(i)
water = sorted(list(set(water)), reverse=True)

suger = []
for i in range(0, F+1, C):
    suger.append(i)
for i in range(0, F+1, D):
    suger.append(i)
suger = sorted(list(set(suger)))

ans_ws = 0
ans_s = 0
node = 0
# 水は多い方、砂糖は少ない方から見ていく
for i in range(len(water)):
    for j in range(len(suger)):
        # 合計量チェック
        if water[i] + suger[j] > F:
            break
        # 溶ける量チェック
        if suger[j] / (water[i] + suger[j]) <= E / (E + 100):
            # 最大濃度更新なら答えを更新
            if suger[j] / (water[i] + suger[j]) > node:
                node = suger[j] / (water[i] + suger[j])
                ans_ws = water[i] + suger[j]
                ans_s = suger[j]
print(str(ans_ws) + " " + str(ans_s))

Submission status: Wrong Answer

Solution code:
import bisect

def line_input(f, type):
    return f(map(type, input().split(" ")))

a,b,c,d,e,f = line_input(tuple, int)

max_dens = 0
ans_w = 0
ans_s = 0

wl = set()
for adx in range(0, f // (a*100) + 1):
    for bdx in range(0, f // (b*100) + 1):
        if adx == 0 & bdx == 0:
            continue

        wl.add(a * adx + b * bdx)

sl = set()
for cdx in range(0, f // c + 1):
    for ddx in range(0, f // d + 1):
        sl.add(c * cdx + d * ddx)

for w in wl:
    if w > f:
        continue

    for s in sl:
        cap = f - w * 100
        C = w * 100 + s

        dens = s / C
        if (C <= f) & (s <= e * w) & (max_dens < dens):
            max_dens = dens
            ans_w = C
            ans_s = s

print(ans_w, ans_s)

Submission status: Wrong Answer

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

A = []
i = 0
while(100*a*i < f):
    A.append(100*a*i)
    i += 1

B = []
i = 0
while(100*b*i < f):
    B.append(100*b*i)
    i += 1

AB = set()
for aa in A:
    for bb in B:
        if aa+bb < f:
            AB.add(aa+bb)
AB.remove(0)

max_sugar = e * f / (100.0 + e)
#print(max_sugar)
C = []
i = 0
while(c*i <= max_sugar):
    C.append(c*i)
    i += 1

D = []
i = 0
while(d*i <= max_sugar):
    D.append(d*i)
    i += 1

CD = set()
for cc in C:
    for dd in D:
        if cc+dd <= max_sugar:
            CD.add(cc+dd)
CD.remove(0)

#print(AB)
#print(CD)

# 全パターン試す
MAX_DENS = e/(e+100.0)
max_dens = 0
max_ws = (0, 0)
for water in AB:
    for sugar in CD:
        weight = water + sugar
        dens = sugar / weight
        if weight > f or dens > MAX_DENS:
            continue
        if max_dens < dens:
            #print(dens, MAX_DENS)
            max_dens = dens
            max_ws = (weight, sugar)
print('%d %d' % max_ws)

Submission status: Wrong Answer

Solution code:
print('100 0')

Submission status: Wrong Answer

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

# あり得る水の量を列挙
A = []
i = 0
while(100*a*i < f):
    A.append(100*a*i)
    i += 1

B = []
i = 0
while(100*b*i < f):
    B.append(100*b*i)
    i += 1

AB = set()
for aa in A:
    for bb in B:
        if aa+bb < f:
            AB.add(aa+bb)
AB.remove(0)

# あり得る砂糖の量を列挙
max_sugar = e * f / (100.0 + e)
#print(max_sugar)
C = []
i = 0
while(c*i <= max_sugar):
    C.append(c*i)
    i += 1

D = []
i = 0
while(d*i <= max_sugar):
    D.append(d*i)
    i += 1

CD = set()
for cc in C:
    for dd in D:
        if cc+dd <= max_sugar:
            CD.add(cc+dd)

#print(AB)
#print(CD)

# 全パターン試す
MAX_DENS = e/(e+100.0)
max_dens = 0
max_ws = (0,0)
for water in AB:
    for sugar in CD:
        weight = water + sugar
        dens = sugar / weight
        if weight > f or dens > MAX_DENS:
            continue
        if max_dens < dens:
            #print(dens, MAX_DENS)
            max_dens = dens
            max_ws = (weight, sugar)
print('%d %d' % max_ws)

Submission status: Wrong Answer

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

# あり得る水の量を列挙
A = []
i = 0
while(100*a*i < f):
    A.append(100*a*i)
    i += 1

B = []
i = 0
while(100*b*i < f):
    B.append(100*b*i)
    i += 1

AB = set()
for aa in A:
    for bb in B:
        if aa+bb < f:
            AB.add(aa+bb)

# あり得る砂糖の量を列挙
max_sugar = e * f / (100.0 + e)
#print(max_sugar)
C = []
i = 0
while(c*i <= max_sugar):
    C.append(c*i)
    i += 1

D = []
i = 0
while(d*i <= max_sugar):
    D.append(d*i)
    i += 1

CD = set()
for cc in C:
    for dd in D:
        if cc+dd <= max_sugar:
            CD.add(cc+dd)

#print(AB)
#print(CD)

# 全パターン試す
MAX_DENS = e/(e+100.0)
max_dens = 0
max_ws = (0,0)
for ab in AB:
    for cd in CD:
        if ab == 0:
            continue
        w = ab + cd
        dens = 1.0 * cd / w
        if w > f or dens > MAX_DENS:
            continue
        if max_dens < dens:
            #print(dens, MAX_DENS)
            max_dens = dens
            max_ws = (w, cd)
print('%d %d' % max_ws)

Submission status: Wrong Answer

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

A = []
i = 0
while(100*a*i < f):
    A.append(100*a*i)
    i += 1

B = []
i = 0
while(100*b*i < f):
    B.append(100*b*i)
    i += 1

AB = set()
for aa in A:
    for bb in B:
        if aa+bb < f:
            AB.add(aa+bb)

max_sugar = e * f / (100.0 + e)
#print(max_sugar)
C = []
i = 0
while(c*i <= max_sugar):
    C.append(c*i)
    i += 1

D = []
i = 0
while(d*i <= max_sugar):
    D.append(d*i)
    i += 1

CD = set()
for cc in C:
    for dd in D:
        if cc+dd <= max_sugar:
            CD.add(cc+dd)

#print(AB)
#print(CD)

MAX_DENS = e/(e+100.0)
max_dens = 0
max_ws = (0,0)
for ab in AB:
    for cd in CD:
        if ab == 0:
            continue
        w = ab + cd
        dens = cd / w
        if w > f or dens > MAX_DENS:
            continue
        if max_dens < dens:
            #print(dens, MAX_DENS)
            max_dens = dens
            max_ws = (w, cd)
print('%d %d' % max_ws)

Submission status: Wrong Answer

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

upper_concentration = E / (100 + E)

def concentration(sugar, water):
    if sugar == 0 and water == 0:
        return False
    c = sugar / (sugar + water)
    if c > upper_concentration:
        return False
    else:
        return c

AB = []
for ia in range(0, int(F / 100) + 1):
    ib = 0
    if ia == 0 and ib == 0:
        continue
    while 100 * (A * ia + B * ib) <= F:
        AB.append([ia, ib])
        ib += 1

c_max = 0
sugar_max = 0
sugar_water_max = 0
abcd = ''
for ia, ib in AB:
    water = 100 * (A * ia + B * ib)
    res_water = F - water
    for ic in range(0, int(res_water / C) + 1):
        for id in range(0, int(res_water / D) + 1):
            sugar = C * ic + D * id
            if sugar > res_water:
                break
            c = concentration(sugar, water)
            if not c:
                continue
            if c_max <= c:
                c_max = c
                sugar_max = sugar
                sugar_water_max = sugar + water
print(sugar_water_max, sugar_max)

Submission status: Wrong Answer

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

upper_concentration = E / (100 + E)

def concentration(sugar, water):
    if sugar == 0 and water == 0:
        return False
    c = sugar / (sugar + water)
    if c > upper_concentration:
        return False
    else:
        return c

AB = []
for ia in range(0, int(F / 100) + 1):
    ib = 0
    if ia == 0 and ib == 0:
        continue
    while 100 * (A * ia + B * ib) < F:
        AB.append([ia, ib])
        ib += 1

c_max = 0
sugar_max = 0
sugar_water_max = 0
abcd = ''
for ia, ib in AB:
    water = 100 * (A * ia + B * ib)
    res_water = F - water
    for ic in range(0, int(res_water / C) + 1):
        for id in range(0, int(res_water / D) + 1):
            sugar = C * ic + D * id
            if sugar > res_water:
                break
            c = concentration(sugar, water)
            if not c:
                continue
            if c_max <= c:
                c_max = c
                sugar_max = sugar
                sugar_water_max = sugar + water
print(sugar_water_max, sugar_max)

Submission status: Wrong Answer

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

upper_concentration = E / (100 + E)

def concentration(sugar, water):
    if sugar == 0 and water == 0:
        return False
    c = sugar / (sugar + water)
    if c > upper_concentration:
        return False
    else:
        return c

AB = []
for ia in range(0, int(F / 100) + 1):
    ib = 0
    if ia == 0 and ib == 0:
        continue
    while 100 * (A * ia + B * ib) < F:
        AB.append([ia, ib])
        ib += 1

c_max = 0
sugar_max = 0
sugar_water_max = 0
abcd = ''
for ia, ib in AB:
    water = 100 * (A * ia + B * ib)
    res_water = F - water
    for ic in range(0, int(res_water / C) + 1):
        for id in range(0, int(res_water / D) + 1):
            sugar = C * ic + D * id
            if sugar > res_water:
                break
            c = concentration(sugar, water)
            if not c:
                continue
            if c_max < c:
                c_max = c
                sugar_max = sugar
                sugar_water_max = sugar + water
print(sugar_water_max, sugar_max)

Submission status: Wrong Answer

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

A = []
i = 0
while(100*a*i < f):
    A.append(100*a*i)
    i += 1

B = []
i = 0
while(100*b*i < f):
    B.append(100*b*i)
    i += 1

AB = set()
for aa in A:
    for bb in B:
        if aa+bb < f:
            AB.add(aa+bb)

C = []
i = 0
while(c*i <= e*f/100.0):
    C.append(c*i)
    i += 1

D = []
i = 0
while(d*i <= e*f/100.0):
    D.append(d*i)
    i += 1

CD = set()
for cc in C:
    for dd in D:
        if cc+dd <= e*f/100.0:
            CD.add(cc+dd)

#print(AB)
#print(CD)

max_dens = 0
max_ws = (0,0)
for ab in AB:
    for cd in CD:
        if ab == 0:
            continue
        w = ab + cd
        dens = cd / w
        if w > f or dens > e/100.0:
            continue
        if max_dens < dens:
            #print(dens, e/100.0)
            max_dens = dens
            max_ws = (w, cd)
print('%d %d' % max_ws)

Submission status: Wrong Answer

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

A = []
i = 0
while(100*a*i < f):
    A.append(100*a*i)
    i += 1

B = []
i = 0
while(100*b*i < f):
    B.append(100*b*i)
    i += 1

AB = set()
for aa in A:
    for bb in B:
        if aa+bb < f:
            AB.add(aa+bb)

C = []
i = 0
while(c*i <= e*100.0/f):
    C.append(c*i)
    i += 1

D = []
i = 0
while(d*i <= e*100.0/f):
    D.append(d*i)
    i += 1

CD = set()
for cc in C:
    for dd in D:
        if cc+dd <= e*100.0/f:
            CD.add(cc+dd)

#print(AB)
#print(CD)

max_dens = 0
max_ws = (0,0)
for ab in AB:
    for cd in CD:
        if ab == 0:
            continue
        w = ab + cd
        dens = cd / w
        if w > f or dens > e/100.0:
            continue
        if max_dens < dens:
            max_dens = dens
            max_ws = (w, cd)
print('%d %d' % max_ws)

Submission status: Wrong Answer

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

# 最大の砂糖の量
max_per = e / (100+e)
max_suger = f * max_per
max_water = f - max_suger

#print(max_per, ' ', max_suger, ' ', max_water)

water = 0
suger = 0
rema = max_water
while True:
    if rema >= 100*b:
        water += b
        rema -= b*100
    elif rema >= 100*a:
        water += a
        rema -= a*100
    else:
        break

rema = min(max_suger, e * water)
#print(rema)
while True:
    if rema >= d :
        suger += d
        rema -= d
    elif rema >= c :
        suger += c
        rema -= c
    else:
        break
print(water*100+suger , ' ', suger)

Submission status: Wrong Answer

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

A = []
i = 0
while(100*a*i < f):
    A.append(100*a*i)
    i += 1

B = []
i = 0
while(100*b*i < f):
    B.append(100*b*i)
    i += 1

AB = set()
for aa in A:
    for bb in B:
        if aa+bb < f:
            AB.add(aa+bb)

C = []
i = 0
while(c*i <= e*f/100):
    C.append(c*i)
    i += 1

D = []
i = 0
while(d*i <= e*f/100):
    D.append(d*i)
    i += 1

CD = set()
for cc in C:
    for dd in D:
        if cc+dd <= e*f/100:
            CD.add(cc+dd)

max_dens = 0
max_ws = (0,0)
for ab in AB:
    for cd in CD:
        if ab == 0:
            continue
        if max_dens < cd/(ab+cd):
            if cd/(ab+cd) > e/100:
                continue
            max_dens = cd/(ab+cd)
            max_ws = (ab+cd, cd)
print('%d %d' % max_ws)

Submission status: Wrong Answer

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

def concentration(sugar, water):
    if sugar == 0 and water == 0:
        return False
    return sugar / (sugar + water)

AB = []
for a in range(0, int(F / 100)+1):
    b = 0
    while 100 * (a + b) < F:
        AB.append([a, b])
        b += 1

c_max = 0
sugar_max = 0
sugar_water_max = 0
for a, b in AB:
    water = 100 * (a + b)
    if water == 0:
        continue
    res_water = F - 100 * (a + b)
    if res_water <= 0:
        continue
    for ic in range(0, int(res_water / C) + 1):
        for id in range(0, int(res_water / D) + 1):
            sugar = C * ic + D * id
            if sugar > res_water:
                continue
            c = concentration(sugar, water)
            if not c:
                continue
            if c > E / (100 + E):
                continue
            if c_max < c:
                c_max = c
                sugar_max = sugar
                sugar_water_max = sugar + water

print(sugar_water_max, sugar_max)