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:
from fractions import gcd
A,B,C,D,E,F = map(int, input().split())
ans = {"w":A*100, "s":0}
def density(water, sugar):
    if water+sugar==0: return -1
    return 100*sugar/(water+sugar)

G = gcd(C,D)
for a in range(F//(100*A)+1):
    for b in range(F//(100*B)+1):
        water = (a*A+b*B)*100
        max_sugar = min((a*A+b*B)*E, F-water)
        sugar = G*(max_sugar//G)
        if density(water, sugar)<0: 
            continue
        if water+sugar>F: 
            continue
        if density(water, sugar)>density(ans["w"], ans["s"]):
            ans["w"] = water
            ans["s"] = sugar
print(ans["w"]+ans["s"], ans["s"])

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A,B,C,D,E,F = map(int, input().split())
ans = {"w":A*100, "s":0}
def density(water, sugar):
    if water+sugar==0: return -1
    return 100*sugar/(water+sugar)

G = gcd(C,D)
for a in range(F//(100*A)+1):
    for b in range(F//(100*B)+1):
        max_sugar = (a*A+b*B)*E
        sugar = G*(max_sugar//G)
        water = (a*A+b*B)*100
        if density(water, sugar)<0: 
            continue
        if water+sugar>F: 
            continue
        if density(water, sugar)>density(ans["w"], ans["s"]):
            ans["w"] = water
            ans["s"] = sugar
print(ans["w"]+ans["s"], ans["s"])

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A,B,C,D,E,F = map(int, input().split())
ans = {"w":A*100, "s":0}
def density(water, sugar):
    if water+sugar==0: return -1
    return 100*sugar/(water+sugar)

G = gcd(C,D)
for a in range(F//(100*A)+1):
    for b in range(F//(100*B)+1):
        max_sugar = (a*A+b*B)*E
        sugar = G*(max_sugar//G)
        water = (a*A+b*B)*100
        if density(sugar,water)<0: 
            continue
        if water+sugar>F: 
            continue
        if density(sugar,water)>density(ans["w"], ans["s"]):
            ans["w"] = water
            ans["s"] = sugar
print(ans["w"]+ans["s"], ans["s"])

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A,B,C,D,E,F = map(int, input().split())
ans = {"w":114514, "s":0}
def density(water, sugar):
    if water+sugar==0: return -1
    return 100*sugar/(water+sugar)

G = gcd(C,D)
for a in range(F//(100*A)+1):
    for b in range(F//(100*B)+1):
        max_sugar = (a*A+b*B)*E
        sugar = G*(max_sugar//G)
        water = (a*A+b*B)*100
        if density(sugar,water)<0: 
            continue
        if water+sugar>F: 
            continue
        if density(sugar,water)>density(ans["w"], ans["s"]):
            ans["w"] = water
            ans["s"] = sugar
print(ans["w"]+ans["s"], ans["s"])

Submission status: Wrong Answer

Solution code:
# a, b <= 30, c, d <= 3*10**5なので全探索

a, b, c, d, e, f = map(int, input().split())
A = [0, 0, 0]

for i in range(f//(100*a) + 1):
    for j in range(f//(100*b) + 1):
        if i == 0 and j == 0:
            continue
        wa = 100*(a*i + b*j)
        maxsu = e*(a*i + b*j)
        re = f - wa
        if re < 0:
            continue
        cansu = min(re, maxsu)
        maxk = cansu//c
        for k in range(maxk+1):
            l = (cansu - k*c)//d
            if l < 0:
                l = 0
            su = k*c + l*d
            if 100*su/(wa+su) > A[0]:
                A = [100*su/(wa+su), wa+su, su]

print(A[1], A[2])

Submission status: Wrong Answer

Solution code:
# a, b <= 30, c, d <= 3*10**5なので全探索

a, b, c, d, e, f = map(int, input().split())
A = [0, 0, 0]

for i in range(f//(100*a) + 1):
    for j in range(f//(100*b) + 1):
        if i == 0 and j == 0:
            continue
        wa = 100*(a*i + b*j)
        maxsu = e*(a*i + b*j)
        re = f - wa
        if re < 0:
            continue
        cansu = min(re, maxsu)
        maxk = cansu//c
        for k in range(maxk+1):
            l = (cansu - k*c)//d
            su = k*c + l*d
            if 100*su/(wa+su) > A[0]:
                A = [100*su/(wa+su), wa+su, su]

print(A[1], A[2])

Submission status: Wrong Answer

Solution code:
# a, b <= 30, c, d <= 3*10**5なので全探索

a, b, c, d, e, f = map(int, input().split())
A = [0, 0, 0]

for i in range(f//(100*a) + 1):
    for j in range(f//(100*b) + 1):
        if i == 0 and j == 0:
            continue
        wa = 100*(a*i + b*j)
        maxsu = e*(a*i + b*j)
        re = f - wa
        cansu = min(re, maxsu)
        maxk = cansu//c
        for k in range(maxk+1):
            l = (cansu - k*c)//d
            su = k*c + l*d
            if 100*su/(wa+su) > A[0]:
                A = [100*su/(wa+su), wa+su, su]

print(A[1], A[2])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
x=1
y=-1
for i in range(0,f,a*100):
    for j in range(0,f-i,b*100):
        s=min(f-i-j,(i+j)*e//100)
        if i+j==0:
            continue
        else:
            for p in range(0,s,c):
                for q in range(0,s-p,d):
                    if y/x<=(p+q)/(i+j):
                        y=p+q
                        x=i+j
print(x+y,y)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
w=F/2
dp=[-1 for _ in range(5000)]

dp[0]=1 #砂糖が入っているか
for i in range(1500):
        dp[i+C]=dp[i]
        dp[i+D]=dp[i]

for i in reversed(range(1500)):
        if(dp[i]==1 and i<=(w//100)*E):
                print(int(w+i),i)
                break

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
if c/a<=e and 100*a+c<=f:
  print(100*a+c)
  print(c)
else:
  print(100*a)
  print(c)

Submission status: Wrong Answer

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

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

    A100 = A * 100
    B100 = B * 100


    d_max = 0
    d_w = 0
    d_s = 0

    i2_max = F // B100 + 1
    for i2 in range(i2_max):
        w2 = B100 * i2
        i1_max = (F - w2) // A100 + 1
        for i1 in range(i1_max):
            w = w2 + A100 * i1
            if w == 0:
                continue
            if F <= w:
                break
            target = (w // 100) * E
            if F - w < target:
                target = F - w
            if target / (w + target) < d_max:
                continue
            q = target // (C * D)
            r = target % (C * D)
            r_max = 0
            for i3 in range(D + 1):
                x3 = C * i3
                if r < x3:
                    break
                if x3 == r:
                    r_max = r
                    break
                for i4 in range(C + 1):
                    x = x3 + D * i4
                    if r < x:
                        break
                    if x == r:
                        r_max = r
                        break
                    r_max = max(r_max, x)
                if r_max == r:
                    break
            s = C * D * q + r_max
            d = s / (w + s)
            if d_max < d:
                d_max = d
                d_w = w
                d_s = s

    print('{} {}'.format(d_w + d_s, d_s))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8

from fractions import Fraction
from collections import Counter, defaultdict

II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    A, B, C, D, E, F = MI()
    A *= 100
    B *= 100

    water_ws = set()
    for a in range(F//A + 1):
        for b in range(F//B + 1):
            w = a * A + b * B
            if w <= F: water_ws.add(w)
    water_ws.remove(0)
    sugar_w_max = max([ww // 100 * E for ww in water_ws])
    sugar_ws = set()
    for c in range(sugar_w_max // C):
        for d in range(sugar_w_max // D):
            w = c * C + d * D
            if w <= sugar_w_max: sugar_ws.add(w)
    ans_w, ans_s = 0, 0
    dens_max = -1
    for ww in water_ws:
        for sw in sugar_ws:
            dens = Fraction(sw, ww + sw)
            if ww + sw <= F and sw <= ww // 100 * E and dens > dens_max:
                ans_w = ww + sw
                ans_s = sw
                dens_max = dens
    print(ans_w, ans_s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8

from fractions import Fraction
from collections import Counter, defaultdict

II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    A, B, C, D, E, F = MI()
    A *= 100
    B *= 100

    water_ws = set()
    for a in range(F//A + 1):
        for b in range(F//B + 1):
            w = a * A + b * B
            if w <= F: water_ws.add(w)
    water_ws.remove(0)
    sugar_w_max = max([ww // 100 * E for ww in water_ws])
    sugar_ws = set()
    for c in range(sugar_w_max // C):
        for d in range(sugar_w_max // D):
            w = c * C + d * D
            if w <= sugar_w_max: sugar_ws.add(w)
    ans_w, ans_s = 0, 0
    dens_max = Fraction(0, 1)
    for ww in water_ws:
        for sw in sugar_ws:
            dens = Fraction(sw, ww + sw)
            if ww + sw <= F and sw <= ww // 100 * E and dens > dens_max:
                ans_w = ww + sw
                ans_s = sw
                dens_max = dens
    print(ans_w, ans_s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

dp_w = [[0 for j in range(101)] for i in range(3)]

for j in range(101):
    if j<a:
        dp_w[1][j] = dp_w[0][j]
    elif j==a:
        dp_w[1][j] = 1
    else:
        if dp_w[0][j]==1 or dp_w[1][j-a]==1:
            dp_w[1][j] = 1
 
for j in range(101):
    if j<b:
        dp_w[2][j] = dp_w[1][j]
    elif j==b:
        dp_w[2][j] = 1
    else:
        if dp_w[1][j]==1 or dp_w[2][j-b]==1:
            dp_w[2][j] = 1           

dp_s = [[0 for j in range(10001)] for i in range(3)]

for j in range(10001):
    if j<c:
        dp_s[1][j] = dp_s[0][j]
    elif j==c:
        dp_s[1][j] = 1
    else:
        if dp_s[0][j]==1 or dp_s[1][j-c]==1:
            dp_s[1][j] = 1
 
for j in range(10001):
    if j<d:
        dp_s[2][j] = dp_s[1][j]
    elif j==d:
        dp_s[2][j] = 1
    else:
        if dp_s[1][j]==1 or dp_s[2][j-d]==1:
            dp_s[2][j] = 1  

nodo = 0.0
ans_s = 0
ans_all = 0

for i in range(101):
    if dp_w[2][i]==1:
        Max_s = e*i
        now_s = 0
        now_w = 100*i
        for j in range(10001):
            if dp_s[2][j]==1 and j+100*i<=f and j<=Max_s:
                now_s = j
        if now_s+now_w>0:
            if nodo<now_s/(now_s+now_w):
                nodo = now_s/(now_s+now_w)
                ans_s = now_s
                ans_all = now_w+now_s
      
ans = [str(ans_all), str(ans_s)]
        
print(' '.join(ans))

Submission status: Wrong Answer

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

dp_w = [[0 for j in range(31)] for i in range(3)]

for j in range(31):
    if j<a:
        dp_w[1][j] = dp_w[0][j]
    elif j==a:
        dp_w[1][j] = 1
    else:
        if dp_w[0][j]==1 or dp_w[1][j-a]==1:
            dp_w[1][j] = 1
 
for j in range(31):
    if j<b:
        dp_w[2][j] = dp_w[1][j]
    elif j==b:
        dp_w[2][j] = 1
    else:
        if dp_w[1][j]==1 or dp_w[2][j-b]==1:
            dp_w[2][j] = 1           

dp_s = [[0 for j in range(3001)] for i in range(3)]

for j in range(3001):
    if j<c:
        dp_s[1][j] = dp_s[0][j]
    elif j==c:
        dp_s[1][j] = 1
    else:
        if dp_s[0][j]==1 or dp_s[1][j-c]==1:
            dp_s[1][j] = 1
 
for j in range(3001):
    if j<d:
        dp_s[2][j] = dp_s[1][j]
    elif j==d:
        dp_s[2][j] = 1
    else:
        if dp_s[1][j]==1 or dp_s[2][j-d]==1:
            dp_s[2][j] = 1  

nodo = 0.0
ans_s = 0
ans_all = 0

for i in range(31):
    if dp_w[2][i]==1:
        Max_s = e*i
        now_s = 0
        now_w = 100*i
        for j in range(3001):
            if dp_s[2][j]==1 and j+100*i<=f and j<=Max_s:
                now_s = j
        if now_w>0:
            if nodo<now_s/now_w:
                nodo = now_s/now_w
                ans_s = now_s
                ans_all = now_w+now_s
      
ans = [str(ans_all), str(ans_s)]
        
print(' '.join(ans))

Submission status: Wrong Answer

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

dp_w = [[0 for j in range(31)] for i in range(3)]

for j in range(31):
    if j<a:
        dp_w[1][j] = dp_w[0][j]
    elif j==a:
        dp_w[1][j] = 1
    else:
        if dp_w[0][j]==1 or dp_w[1][j-a]==1:
            dp_w[1][j] = 1
 
for j in range(31):
    if j<b:
        dp_w[2][j] = dp_w[1][j]
    elif j==b:
        dp_w[2][j] = 1
    else:
        if dp_w[1][j]==1 or dp_w[2][j-b]==1:
            dp_w[2][j] = 1           

dp_s = [[0 for j in range(3001)] for i in range(3)]

for j in range(3001):
    if j<c:
        dp_s[1][j] = dp_s[0][j]
    elif j==c:
        dp_s[1][j] = 1
    else:
        if dp_s[0][j]==1 or dp_s[1][j-c]==1:
            dp_s[1][j] = 1
 
for j in range(3001):
    if j<d:
        dp_s[2][j] = dp_s[1][j]
    elif j==d:
        dp_s[2][j] = 1
    else:
        if dp_s[1][j]==1 or dp_s[2][j-d]==1:
            dp_s[2][j] = 1  

nodo = 0
ans_s = 0
ans_all = 0

for i in range(31):
    if dp_w[2][i]==1:
        Max_s = e*i
        now_s = 0
        now_w = 100*i
        for j in range(3001):
            if dp_s[2][j]==1 and j+100*i<=f and j<=Max_s:
                now_s = j
        if now_w>0:
            if nodo<now_s/now_w:
                nodo = now_s/now_w
                ans_s = now_s
                ans_all = now_w+now_s
      
ans = [str(ans_all), str(ans_s)]
        
print(' '.join(ans))

Submission status: Wrong Answer

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

dp_w = [[0 for j in range(31)] for i in range(3)]

for j in range(31):
    if j<a:
        dp_w[1][j] = dp_w[0][j]
    elif j==a:
        dp_w[1][j] = 1
    else:
        if dp_w[0][j]==1 or dp_w[1][j-a]==1:
            dp_w[1][j] = 1
 
for j in range(31):
    if j<b:
        dp_w[2][j] = dp_w[1][j]
    elif j==b:
        dp_w[2][j] = 1
    else:
        if dp_w[1][j]==1 or dp_w[2][j-b]==1:
            dp_w[2][j] = 1           

dp_s = [[0 for j in range(3001)] for i in range(3)]

for j in range(3001):
    if j<c:
        dp_s[1][j] = dp_s[0][j]
    elif j==c:
        dp_s[1][j] = 1
    else:
        if dp_s[0][j]==1 or dp_s[1][j-c]==1:
            dp_s[1][j] = 1
 
for j in range(3001):
    if j<d:
        dp_s[2][j] = dp_s[1][j]
    elif j==d:
        dp_s[2][j] = 1
    else:
        if dp_s[1][j]==1 or dp_s[2][j-d]==1:
            dp_s[2][j] = 1  

nodo = 0
ans_s = 0
ans_all = 0

for i in range(31):
    if dp_w[2][i]==1:
        Max_s = e*i
        now_ans = 0
        now_all = 0
        for j in range(3001):
            if dp_s[2][j]==1 and j+100*i<=f and j<=Max_s:
                now_ans = j
                now_all = j+100*i
        if now_all>0:
            if nodo<now_ans/now_all:
                nodo = now_ans/now_all
                ans_s = now_ans
                ans_all = now_all
      
ans = [str(ans_all), str(ans_s)]
        
print(' '.join(ans))

Submission status: Wrong Answer

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

dp_w = [[0 for j in range(31)] for i in range(3)]

for j in range(31):
    if j<a:
        dp_w[1][j] = dp_w[0][j]
    elif j==a:
        dp_w[1][j] = 1
    else:
        if dp_w[0][j]==1 or dp_w[1][j-a]==1:
            dp_w[1][j] = 1
 
for j in range(31):
    if j<b:
        dp_w[2][j] = dp_w[1][j]
    elif j==b:
        dp_w[2][j] = 1
    else:
        if dp_w[1][j]==1 or dp_w[2][j-b]==1:
            dp_w[2][j] = 1           

dp_s = [[0 for j in range(3001)] for i in range(3)]

for j in range(3001):
    if j<c:
        dp_s[1][j] = dp_s[0][j]
    elif j==c:
        dp_s[1][j] = 1
    else:
        if dp_s[0][j]==1 or dp_s[1][j-c]==1:
            dp_s[1][j] = 1
 
for j in range(3001):
    if j<d:
        dp_s[2][j] = dp_s[1][j]
    elif j==d:
        dp_s[2][j] = 1
    else:
        if dp_s[1][j]==1 or dp_s[2][j-d]==1:
            dp_s[2][j] = 1  

ans_s = 0
ans_all = 0

for i in range(31):
    if dp_w[2][i]==1:
        Max_s = e*i
        now_ans = 0
        now_all = 0
        for j in range(3001):
            if dp_s[2][j]==1 and j+100*i<=f and j<=Max_s:
                now_ans = j
                now_all = j+100*i
        if ans_s<now_ans:
            ans_s = now_ans
            ans_all = now_all
      
ans = [str(ans_all), str(ans_s)]
        
print(' '.join(ans))

Submission status: Wrong Answer

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


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

    for i in range(30 + 1):
        for j in range(30 + 1):
            if 100 * a * i + 100 * b * j <= f:
                ab.append((i, j))

    for x in range(100 + 1):
        for y in range(100 + 1):
            if c * x + d * y <= 30 * e:
                cd.append((x, y))

    ans = 0
    ans_water = 0
    ans_sugar = 0

    for i, j in ab:
        for x, y in cd:
            total_water = 100 * (a * i + b * j)
            total_sugar = c * x + d * y

            if total_water > 0 and total_water + total_sugar <= f and total_sugar <= e * total_water // 100:
                rate = 100 * total_sugar / (total_water + total_sugar)

                if rate - ans > 0:
                    ans = rate
                    ans_water = total_water
                    ans_sugar = total_sugar

    print(ans_water + ans_sugar, ans_sugar)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

    for i in range(30 + 1):
        for j in range(30 + 1):
            if 100 * a * i + 100 * b * j <= f:
                ab.append((i, j))

    for x in range(100 + 1):
        for y in range(100 + 1):
            if c * x + d * y <= 30 * e:
                cd.append((x, y))

    ans = 0
    ans_water = 0
    ans_sugar = 0

    for i, j in ab:
        for x, y in cd:
            total_water = 100 * (a * i + b * j)
            total_sugar = c * x + d * y

            if total_water > 0 and total_water + total_sugar <= f and total_sugar <= e * total_water // 100:
                rate = 100 * total_sugar / (total_water + total_sugar)

                if rate - ans > 10 ** -6:
                    ans = rate
                    ans_water = total_water
                    ans_sugar = total_sugar

    print(ans_water + ans_sugar, ans_sugar)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

    for i in range(30 + 1):
        for j in range(30 + 1):
            if 100 * a * i + 100 * b * j <= f:
                ab.append((i, j))

    for x in range(100 + 1):
        for y in range(100 + 1):
            if c * x + d * y <= 30 * e:
                cd.append((x, y))

    ans = 0
    ans_water = 0
    ans_sugar = 0

    for i, j in ab:
        for x, y in cd:
            total_water = 100 * (a * i + b * j)
            total_sugar = c * x + d * y

            if total_water > 0 and total_water + total_sugar <= f and total_sugar <= e * total_water // 100:
                rate = 100 * total_sugar / (total_water + total_sugar)

                if rate - ans >= 10 ** -9:
                    ans = rate
                    ans_water = total_water
                    ans_sugar = total_sugar

    print(ans_water + ans_sugar, ans_sugar)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

    for i in range(30 + 1):
        for j in range(30 + 1):
            if 100 * a * i + 100 * b * j <= f:
                ab.append((i, j))

    for x in range(100 + 1):
        for y in range(100 + 1):
            if c * x + d * y <= (a * i + b * j) * e:
                cd.append((x, y))

    ans = 0
    ans_water = 0
    ans_sugar = 0

    for i, j in ab:
        for x, y in cd:
            total_water = 100 * (a * i + b * j)
            total_sugar = c * x + d * y

            if total_water > 0 and total_water + total_sugar <= f and total_sugar <= e * total_water // 100:
                rate = 100 * total_sugar / (total_water + total_sugar)

                if rate - ans >= 10 ** -9:
                    ans = rate
                    ans_water = total_water
                    ans_sugar = total_sugar

    print(ans_water + ans_sugar, ans_sugar)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

max_sugar = 0
max_water = 100*A
max_conc = 0.0
A_limit = F // (100*A)
for i in range(A_limit + 1):
    B_limit = (F-A*i) // (100*B)
    for j in range(B_limit + 1):
        if i == 0 and j == 0:
            continue
        sugar_limit = min(E * (A*i+B*j), F-100*(A*i+B*j))
        sugar_ = 0
        for c in range(sugar_limit//C + 1):
            d = (sugar_limit-c*C)//D
            temp_sugar = c*C + d*D
            sugar_ = max(sugar_, temp_sugar)
        temp_conc = sugar_/(sugar_+A*i+B*j)
        if temp_conc > max_conc:
            max_conc = max_conc
            max_water = 100*(A*i + B*j)
            max_sugar = sugar_
print('{0} {1}'.format(max_water+max_sugar, max_sugar))

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split(' '))
water = []
for i in range(31):
    if A*i >= F:
        break
    for j in range(16):
        if 100 * (A*i + B*j) < F:
            water.append(100*(A*i+B*j))
        else:
            break
water = sorted(list(set(water)))

sugar = []
for i in range(max(water)//100*E//C + 1):
    for j in range(max(water)//100*E//D + 1):
        temp_sugar = C*i + D*j
        if temp_sugar + water[1] <= F:
            sugar.append(temp_sugar)
        else:
            break
sugar = sorted(list(set(sugar)))

max_conc = 0
ans_W = 100*A
ans_sugar = 0
for W in water:
    if W == 0:
        continue
    for S in sugar:
        if S+W <= F and S < W*E//100:
            if max_conc < S/(W+S):
                max_conc = S/(S+W)
                ans_W = W
                ans_sugar = S
        else:
            break
print('{0} {1}'.format(ans_W+ans_sugar, ans_sugar))

Submission status: Wrong Answer

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

#  すぬけくんが取るアレを総当たり
A_C  = 100*A + C
A_D = 100*A +  D
B_C = 100*B + C
B_D = 100*B + D
if (100.0*C/A_C <= E and A_C <= F):
  print(str(A_C) + " " + str(C))
elif (100.0*D/A_D <= E and A_D <= F):
  print(str(A_D) + " " + str(D))
elif (100.0*B/B_C <= E and B_C <= F):
  print(str(B_C) + " " + str(C))
elif (100.0*B/B_D <= E and B_D <= F):
  print(str(B_D) + " " + str(D))

Submission status: Wrong Answer

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

waters = set()
for a in range(0,F+1,100*A):
    for b in range(0,F+1,100*B):
        if a+b > F:
            break
        waters.add(a+b)
waters.remove(0)

sugars = set()
for c in range(0,F+1,C):
    for d in range(0,F+1,D):
        if c+d > F:
            break
        sugars.add(c+d)

best_r = 0
best_w = best_s = 0

for w in waters:
    for s in sugars:
        if w+s > F: continue
        if E*w < s*100: continue
        r = s / (w+s)
        if r > best_r:
            best_r = r
            best_s = s
            best_w = w
print(best_w+best_s, best_s)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F=map(int, input().split())
wans=0
sans=0
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                w=100*A*i+100*B*j
                s=C*k+D*l
                if s*100<=(s+w)*E and sans*(s+w)<=s*(sans+wans) and w+s<=F:
                    sans=s
                    wans=w
                #print(sans,sans+wans)
print(sans+wans,sans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F=map(int, input().split())
wans=0
sans=0
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                w=100*A*i+100*B*j
                s=C*k+D*l
                if s*100<=(s+w)*E and sans*(s+w)<=s*(sans+wans) and w+s<=F:
                    sans=s
                    wans=w
                #print(sans,sans+wans)
print(sans,sans+wans)

Submission status: Wrong Answer

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


ablist = []

a, b = 0, 0
while (100 * A * a + 100 * B * b <= F):
    while (100 * A * a + 100 * B * b <= F):
        ablist.append((a, b))
        b += 1
    a += 1
    b = 0
ablist.remove((0, 0))

wlist = [100 * A * ab[0] + 100 * B * ab[1] for ab in ablist]
wset = set(wlist)

cdlist = []
c, d = 0, 0
while (C * c + D*d <= F):
    while (C * c + D * d <= F):
        cdlist.append((c, d))
        d += 1
    c += 1
    d = 0

slist = [C * cd[0] + C * cd[1] for cd in cdlist]
sset = set(slist)

max_rate = -1
ret_sw = 0
ret_s = 0

for w in wset:
    for s in sset:
        if s + w <= F:
            rate = s / (s + w)
            if rate <= E/(E+100):
                if max_rate < rate:
                    max_rate = rate
                    ret_sw = s + w
                    ret_s = s

print("{} {}".format(ret_sw, ret_s))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int, input().split())
x,y,z=100*a,0,0
for i in range(31):
    for j in range(31):
        mizu=(a*i+b*j)*100
        if mizu==0 or mizu>f:break
        for k in range(int((f-mizu)//c)+1):
            for l in range(int((f-mizu)//d)+1):
                sato=c*k+d*l
                noudo=100*sato/(mizu+sato)
                if mizu+sato>=f or mizu/100*e<sato:break
                if noudo>z: z,x,y = noudo,mizu+sato,sato
print(x,y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int, input().split())
x,y,z=100*a,0,0
for i in range(31):
    for j in range(31):
        mizu=(a*i+b*j)*100
        if mizu==0 or mizu>f:break
        for k in range(int((f-mizu)//c)+1):
            for l in range(int((f-mizu)//d)+1):
                sato=c*k+d*l
                noudo=100*sato/(mizu+sato)
                if mizu+sato>=f or 100*sato/mizu>e:break
                if noudo>z: z,x,y = noudo,mizu+sato,sato
print(x,y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int, input().split())
x,y,z=0,0,0
for i in range(31):
    for j in range(31):
        mizu=(a*i+b*j)*100
        if mizu==0 or mizu>f:break
        for k in range(int((f-mizu)//c)+1):
            for l in range(int((f-mizu)//d)+1):
                sato=c*k+d*l
                noudo=100*sato/(mizu+sato)
                if mizu+sato>=f or 100*sato/mizu>e:break
                if noudo>z: z,x,y = noudo,mizu+sato,sato
print(x,y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int, input().split())
x,y,z=0,0,0
for i in range(31):
    for j in range(31):
        mizu=a*100*i+b*100*j
        if mizu==0 or mizu>=f:break
        for k in range(int((f-mizu)//c)+10):
            for l in range(int((f-mizu)//d)+10):
                sato=c*k+d*l
                noudo=100*sato/(mizu+sato)
                if mizu+sato>=f or 100*sato/mizu>e:break
                if noudo>z: z,x,y = noudo,mizu+sato,sato
print(x,y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int, input().split())
x,y,z=0,0,0
for i in range(int(f/100//a)+2):
    for j in range(int(f/100//b)+2):
        mizu=a*100*i+b*100*j
        for k in range(int(mizu*e/100//c)+10):
            for l in range(int(mizu*e/100//d)+10):
                sato=c*k+d*l
                if mizu+sato>=f or mizu==0 or sato*100/mizu>e:break
                noudo=100*sato/mizu
                if noudo>z:z,x,y=noudo,mizu+sato,sato
print(x,y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int, input().split())
x,y,z=0,0,0
for i in range(int(f/100//a)+1):
    for j in range(int(f/100//b)+1):
        mizu=a*100*i+b*100*j
        for k in range(int(mizu*e/100//c)+2):
            for l in range(int(mizu*e/100//d)+2):
                sato=c*k+d*l
                if mizu+sato>=f or mizu==0 or sato*100/mizu>e:break
                noudo=100*sato/mizu
                if noudo>z:z,x,y=noudo,mizu+sato,sato
print(x,y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int, input().split())
x,y,z=0,0,0
for i in range(int(f/100//a)+1):
    for j in range(int(f/100//b)+1):
        mizu=a*100*i+b*100*j
        for k in range(int(mizu*e/100//c)+2):
                for l in range(int(mizu*e/100//d)+2):
                    #print(i,j,k,l,mizu,f)
                    sato=c*k+d*l
                    if mizu+sato>=f or mizu==0 or sato*100/mizu>e:break
                    noudo=100*sato//mizu
                    if noudo>z:
                        z=noudo
                        x=mizu+sato
                        y=sato
print(x,y)