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())
# d = b/(a+b)を最大化したい
# 条件1: 100*b <= a*E
# 条件2: a + b <= F
# 条件3: a % (100*gcd(A,B)) == 0
# 条件4: b % gcd(C,D) == 0
# (100A)i + (100B)j = a となる非負整数i,jが存在する => 条件3
# (C)k + (D)l = b となる非負整数k,lが存在する => 条件4
# d <= d'  <=>  b/(a+b) <= b'/(a'+b')  <=>  (a'+b')b <= (a+b)b'
a_d = 100*gcd(A,B); b_d = gcd(C,D)
ans_a = 1; ans_b = 0
candidate = []
# 必要条件で絞り込み
for a in range(a_d,F+1,a_d):
    b_sup = F - a
    for b in range(b_d,b_sup+1,b_d):
        if not(100*b <= a*E and a % a_d == 0 and b % b_d == 0):
            continue
        candidate.append([a,b])
# 十分性の確認
for a, b in candidate:
    cnt = 0
    nA = (100*A) // a_d; nB = (100*B) // a_d; na = a // a_d
    # nAi + nBj = a を満たす非負整数i,jの存在を判定
    # nAi <= na  <=>  i <= na / nA
    for i in range(-(-na // nA)+1):
        # j = (a-Ai) / B, jは整数
        if (na-nA*i) % nB == 0:
            cnt += 1
            break
    nC = C // b_d; nD = D // b_d; nb = b // b_d
    # nCk + nDl = nb を満たす非負整数k,lの存在を判定
    # nCk <= nb  <=>  k <= nb / nC
    for k in range(-(-nb//nC)+1):
        # l = (nb-nCk) / nD, lは整数
        if (nb-nC*k) % nD == 0:
            cnt += 1
            break
    if cnt == 2 and (a+b)*ans_b <= (ans_a+ans_b)*b:
        ans_a = a; ans_b = b
print(ans_a+ans_b,ans_b)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A,B,C,D,E,F = map(int,input().split())
# d = b/(a+b)を最大化したい
# 条件1: 100*b <= a*E
# 条件2: a + b <= F
# 条件3: a % (100*gcd(A,B)) == 0
# 条件4: b % gcd(C,D) == 0
# (100A)i + (100B)j = a となる非負整数i,jが存在する => 条件3
# (C)k + (D)l = b となる非負整数k,lが存在する => 条件4
# d <= d'  <=>  b/(a+b) <= b'/(a'+b')  <=>  (a'+b')b <= (a+b)b'
a_d = 100*gcd(A,B); b_d = gcd(C,D)
ans_a = 1; ans_b = 0
candidate = []
# 必要条件で絞り込み
for a in range(a_d,F+1,a_d):
    b_sup = F - a
    for b in range(b_d,b_sup+1,b_d):
        if not(100*b <= a*E and a % a_d == 0 and b % b_d == 0):
            continue
        if (a+b)*ans_b <= (ans_a+ans_b)*b:
            candidate.append([a,b])
# 十分性の確認
for a, b in candidate:
    cnt = 0
    nA = (100*A) // a_d; nB = (100*B) // a_d; na = a // a_d
    # nAi + nBj = a を満たす非負整数i,jの存在を判定
    # nAi <= na  <=>  i <= na / nA
    for i in range(-(-na // nA)+1):
        # j = (a-Ai) / B, jは整数
        if (na-nA*i) % nB == 0:
            cnt += 1
            break
    nC = C // b_d; nD = D // b_d; nb = b // b_d
    # nCk + nDl = nb を満たす非負整数k,lの存在を判定
    # nCk <= nb  <=>  k <= nb / nC
    for k in range(-(-nb//nC)+1):
        # l = (nb-nCk) / nD, lは整数
        if (nb-nC*k) % nD == 0:
            cnt += 1
            break
    if cnt == 2 and (a+b)*ans_b <= (ans_a+ans_b)*b:
        ans_a = a; ans_b = b
print(ans_a+ans_b,ans_b)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A,B,C,D,E,F = map(int,input().split())
a_d = 100*gcd(A,B); b_d = gcd(C,D)
ans_a = 1; ans_b = 0
for a in range(a_d,F+1,a_d):
    b_sup = F - a
    for b in range(b_d,b_sup+1,b_d):
        if not(100*b <= a*E):
            continue
        if (a+b)*ans_b <= (ans_a+ans_b)*b:
            ans_a = a; ans_b = b
print(ans_a+ans_b,ans_b)

Submission status: Wrong Answer

Solution code:
import sys
import math
def calc_ratio(a, b):
    if b == 0:
        return 0
    else:
        return b / float(a + b)

A, B, C, D, E, F = map(int, raw_input().split())
res_r = -1
res_w = 0
res_s = 0
ideal_r = calc_ratio(100, E)

for a in (100 * A * i for i in xrange(31) if 100 * A * i <= F):
    for b in (100 * B * i for i in xrange(31) if a + 100 * B * i <= F):
        if a + b == 0:
            continue

        for c in (C * i for i in xrange(1501) if a + b + C * i <= F):
            if calc_ratio(a + b, c) > ideal_r:
                break
            d = min(float(ideal_r * (a + b + c) - c) / (1 - ideal_r),
                    F - a - b - c)
            d = int(d / D) * D
            r = calc_ratio(a + b, c + d)
            if res_r < r:
                res_r = r
                res_w = a + b
                res_s = c + d
                
print int(res_w + res_s), int(res_s)

Submission status: Wrong Answer

Solution code:
import sys
import math
def calc_ratio(a, b):
    if b == 0:
        return 0
    else:
        return b / float(a + b)

A, B, C, D, E, F = map(int, raw_input().split())
res_r = 0
res_w = 0
res_s = 0
ideal_r = calc_ratio(100, E)

for a in (100 * A * i for i in xrange(31) if 100 * A * i <= F):
    for b in (100 * B * i for i in xrange(31) if a + 100 * B * i <= F):
        if a + b == 0:
            continue

        for c in (C * i for i in xrange(1501) if a + b + C * i <= F):
            if calc_ratio(a + b, c) > ideal_r:
                break
            d = min(float(ideal_r * (a + b + c) - c) / (1 - ideal_r),
                    F - a - b - c)
            d = int(d / D) * D
            r = calc_ratio(a + b, c + d)
            if res_r <= r:
                res_r = r
                res_w = a + b
                res_s = c + d
                
print int(res_w + res_s), int(res_s)

Submission status: Wrong Answer

Solution code:
import sys
import math
def calc_ratio(a, b):
    try:
        return b / float(a + b)
    except ZeroDivisionError:
        sys.exit('zero division error')
A, B, C, D, E, F = map(int, raw_input().split())
res_r = 0
res_w = 0
res_s = 0
ideal_r = calc_ratio(100, E)

for a in (100 * A * i for i in xrange(31) if 100 * A * i < F):
    for b in (100 * B * i for i in xrange(31) if a + 100 * B * i < F):
        if a + b == 0:
            continue

        for c in (C * i for i in xrange(1501) if a + b + C * i <= F):
            if calc_ratio(a + b, c) > ideal_r:
                break
            d = min(float(ideal_r * (a + b + c) - c) / (1 - ideal_r),
                    F - a - b - c)
            d = int(d / D) * D
            if c + d == 0:
                continue
            r = calc_ratio(a + b, c + d)
            if res_r < r:
                res_r = r
                res_w = a + b
                res_s = c + d
                
print int(res_w + res_s), int(res_s)

Submission status: Wrong Answer

Solution code:
import sys
import math
def calc_ratio(a, b):
    try:
        return b / float(a + b)
    except ZeroDivisionError:
        sys.exit('zero division error')
A, B, C, D, E, F = map(int, raw_input().split())
res_r = 0
res_w = 0
res_s = 0
ideal_r = calc_ratio(100, E)

for a in (100 * A * i for i in xrange(31) if 100 * A * i < F):
    for b in (100 * B * i for i in xrange(31) if a + 100 * B * i < F):
        if a + b == 0:
            continue

        for c in (C * i for i in xrange(1501) if a + b + C * i <= F):
            if calc_ratio(a + b, c) > ideal_r:
                break
            d = min((ideal_r * (a + b + c) - c) / (1 - ideal_r),
                    F - a - b - c)
            d = int(d / D) * D
            if c + d == 0:
                continue
            r = calc_ratio(a + b, c + d)
            if res_r < r:
                res_r = r
                res_w = a + b
                res_s = c + d
                
print int(res_w + res_s), int(res_s)

Submission status: Wrong Answer

Solution code:
import sys
import math
def calc_ratio(a, b):
    try:
        return b / float(a + b)
    except ZeroDivisionError:
        sys.exit('zero division error')
A, B, C, D, E, F = map(int, raw_input().split())
res_r = 0
res_w = 0
res_s = 0
ideal_r = calc_ratio(100, E)

for a in (100 * A * i for i in xrange(31) if 100 * A * i <= F):
    for b in (100 * B * i for i in xrange(31) if a + 100 * B * i <= F):
        if a + b == 0:
            continue

        for c in (C * i for i in xrange(1501) if a + b + C * i <= F):
            if calc_ratio(a + b, c) > ideal_r:
                break
            d = min((ideal_r * (a + b + c) - c) / (1 - ideal_r),
                    F - a - b - c)
            d = int(d / D) * D
            if c + d == 0:
                continue
            r = calc_ratio(a + b, c + d)
            if res_r < r:
                res_r = r
                res_w = a + b
                res_s = c + d
                
print int(res_w + res_s), int(res_s)

Submission status: Wrong Answer

Solution code:
import sys
import math
def calc_ratio(a, b):
    try:
        return b / float(a + b)
    except ZeroDivisionError:
        sys.exit('zero division error')
A, B, C, D, E, F = map(int, raw_input().split())
res_r = 0
res_w = 0
res_s = 0
ideal_r = calc_ratio(100, E)

for a in (100 * A * i for i in xrange(31) if 100 * A * i <= F):
    for b in (100 * B * i for i in xrange(31) if a + 100 * B * i <= F):
        if a + b == 0:
            continue

        for c in (C * i for i in xrange(1501) if a + b + C * i <= F):
            if calc_ratio(a + b, c) > ideal_r:
                break
            d = max(
                min(int(math.floor((ideal_r * (a + b + c) - c) / (1 - ideal_r)) / D) * D,
                    int((F - a - b - c) / D) * D),
                min(int(math.ceil((ideal_r * (a + b + c) - c) / (1 - ideal_r)) / D) * D,
                    int((F - a - b - c) / D) * D)
            )
            if c + d == 0:
                continue
            r = calc_ratio(a + b, c + d)
            if res_r < r:
                res_r = r
                res_w = a + b
                res_s = c + d
                
print int(res_w + res_s), int(res_s)

Submission status: Wrong Answer

Solution code:
import math

def calc_ratio(a, b):
    if a + b == 0:
        return 2.
    else:
        return b / float(a + b)
A, B, C, D, E, F = map(int, raw_input().split())
res_r = 0
res_w = 0
res_s = 0
ideal_r = calc_ratio(100, E)
for a in (100 * A * i for i in xrange(31) if 100 * A *i <= F):
    for b in (100 * B * i for i in xrange(31) if 100 * B * i <= F):
        for c in (i for i in xrange(1501) if i % C == 0):
            if calc_ratio(a + b, c) > ideal_r or a + b + c > F:
                break
            d = min((ideal_r * (a + b + c) - c) / (1 - ideal_r),
                    F - a - b - c)
            d = int(d / D) * D
            r = calc_ratio(a + b, c + d)
            if res_r < r:
                res_r = r
                res_w = a + b
                res_s = c + d
                
print int(res_w + res_s), int(res_s)

Submission status: Wrong Answer

Solution code:
import math

def calc_ratio(a, b):
    if a + b == 0:
        return 2.
    else:
        return b / float(a + b)
A, B, C, D, E, F = map(int, raw_input().split())
res_a = 0
res_b = 0
res_r = 0
ideal_r = calc_ratio(100, E)
for a1 in (100 * A * i for i in xrange(31)):
    for a2 in (100 * B * i for i in xrange(31)):
        for b1 in (i for i in xrange(3000) if i % C == 0):
            a = a1 + a2
            if a + b1 > F:
                continue
            ideal_b = a * ideal_r / float(1 - ideal_r)
            b2 = int(max(0, ideal_b - b1) / float(D)) * D
            if b2 > F - a - b1:
                b2 -= math.ceil(float(b2 - (F - a - b1)) / D) * D
            b = b1 + b2
            r = calc_ratio(a, b)
            if res_r < r and r <= ideal_r and a + b <= F:
                res_r = r
                res_a = a
                res_b = b
print int(res_a + res_b), int(res_b)

Submission status: Wrong Answer

Solution code:
import math

def calc_ratio(a, b):
    if a + b == 0:
        return 2.
    else:
        return b / float(a + b)
A, B, C, D, E, F = map(int, raw_input().split())
res_a = 0
res_b = 0
res_r = 0
ideal_r = calc_ratio(100, E)
for a1 in (100 * A * i for i in xrange(31)):
    for a2 in (100 * B * i for i in xrange(31)):
        for b1 in (i for i in xrange(3000) if i % C == 0):
            a = a1 + a2
            if a + b1 > F:
                continue
            ideal_b = a * ideal_r / float(1 - ideal_r)
            b2 = int(max(0, ideal_b - b1) / float(D)) * D
            if b2 > F - a - b1:
                continue
            b = b1 + b2
            r = calc_ratio(a, b)
            if res_r < r and r <= ideal_r and a + b <= F:
                res_r = r
                res_a = a
                res_b = b
print int(res_a + res_b), int(res_b)

Submission status: Wrong Answer

Solution code:
import math

def calc_ratio(a, b):
    if a + b == 0:
        return 2.
    else:
        return b / float(a + b)
A, B, C, D, E, F = map(int, raw_input().split())
res_a = 0
res_b = 0
res_r = 0
ideal_r = calc_ratio(100, E)
for a1 in (100 * A * i for i in xrange(31)):
    for a2 in (100 * B * i for i in xrange(31)):
        for b1 in (i for i in xrange(1501) if i % C == 0):
            a = a1 + a2
            if a + b1 > F:
                continue
            ideal_b = a * ideal_r / float(1 - ideal_r)
            b2 = int(max(0, ideal_b - b1) / float(D)) * D
            if b2 > F - a - b1:
                continue
            b = b1 + b2
            r = calc_ratio(a, b)
            if res_r < r and r <= ideal_r and a + b <= F:
                res_r = r
                res_a = a
                res_b = b
print int(res_a + res_b), int(res_b)

Submission status: Wrong Answer

Solution code:
import math

def calc_ratio(a, b):
    if a + b == 0:
        return 2.
    else:
        return b / float(a + b)
A, B, C, D, E, F = map(int, raw_input().split())
res_a = 0
res_b = 0
res_r = 0
ideal_r = calc_ratio(100, E)
for a1 in (100 * A * i for i in xrange(31)):
    for a2 in (100 * B * i for i in xrange(31)):
        for b1 in (i for i in xrange(1501) if i % C == 0):
            a = a1 + a2
            if a + b1 > F:
                continue
            ideal_b = a * ideal_r / float(1 - ideal_r)
            b2 = min(int(max(0, ideal_b - b1) / float(D)) * D, F - a - b1)
            b = b1 + b2
            r = calc_ratio(a, b)
            if res_r < r and r <= ideal_r and a + b <= F:
                res_r = r
                res_a = a
                res_b = b
print int(res_a + res_b), int(res_b)

Submission status: Wrong Answer

Solution code:
import math

def calc_ratio(a, b):
    if a + b == 0:
        return 2.
    else:
        return b / float(a + b)
A, B, C, D, E, F = map(int, raw_input().split())
res_a = 0
res_b = 0
res_r = 0
ideal_r = calc_ratio(100, E)
for a1 in (100 * A * i for i in xrange(16)):
    for a2 in (100 * B * i for i in xrange(16)):
        for b1 in (i for i in xrange(1501) if i % C == 0):
            a = a1 + a2
            if a + b1 > F:
                continue
            ideal_b = a * ideal_r / float(1 - ideal_r)
            b2 = min(int(max(0, ideal_b - b1) / float(D)) * D, F - a - b1)
            b = b1 + b2
            r = calc_ratio(a, b)
            if res_r < r and r <= ideal_r and a + b <= F:
                res_r = r
                res_a = a
                res_b = b
print int(res_a + res_b), int(res_b)

Submission status: Wrong Answer

Solution code:
import math

def calc_ratio(a, b):
    if a + b == 0:
        return 2.
    else:
        return b / float(a + b)
A, B, C, D, E, F = map(int, raw_input().split())
res_a = 0
res_b = 0
res_r = 0
ideal_r = calc_ratio(100, E)
for a1 in (100 * A * i for i in xrange(16)):
    for a2 in (100 * B * i for i in xrange(16)):
        for b1 in (i for i in xrange(1501) if i % C == 0):
            a = a1 + a2
            ideal_b = a * ideal_r / float(1 - ideal_r)
            b2 = min(int(max(0, ideal_b - b1) / float(D)) * D, F - a - b1)
            b = b1 + b2
            r = calc_ratio(a, b)
            if res_r < r and r <= ideal_r and a + b <= F:
                res_r = r
                res_a = a
                res_b = b
print int(res_a + res_b), int(res_b)

Submission status: Wrong Answer

Solution code:
import math

def calc_ratio(a, b):
    if a + b == 0:
        return 2.
    else:
        return b / float(a + b)
A, B, C, D, E, F = map(int, raw_input().split())
res_a = 0
res_b = 0
res_r = 0
ideal_r = calc_ratio(100, E)
for a1 in (100 * A * i for i in xrange(31)):
    for a2 in (200 * B * i for i in xrange(31)):
        for b1 in (i for i in xrange(1501) if i % C == 0):
            a = a1 + a2
            ideal_b = a * ideal_r / float(1 - ideal_r)
            b2 = min(int(max(0, ideal_b - b1) / float(D)) * D, F - a - b1)
            b = b1 + b2
            r = calc_ratio(a, b)
            if res_r < r and r <= ideal_r and a + b <= F:
                res_r = r
                res_a = a
                res_b = b
print int(res_a + res_b), int(res_b)

Submission status: Wrong Answer

Solution code:
import math

def calc_ratio(a, b):
    if a + b == 0:
        return 2.
    else:
        return b / float(a + b)
A, B, C, D, E, F = map(int, raw_input().split())
res_a = 0
res_b = 0
res_r = 0
ideal_r = calc_ratio(100, E)
for a1 in (100 * A * i for i in xrange(31)):
    for a2 in (200 * B * i for i in xrange(31)):
        for b1 in (i for i in xrange(3001) if i % C == 0):
            a = a1 + a2
            ideal_b = a * ideal_r / float(1 - ideal_r)
            b2 = min(round(max(0, ideal_b - b1) / float(D)) * D, F - a - b1)
            b = b1 + b2
            r = calc_ratio(a, b)
            if res_r < r and r <= ideal_r and a + b <= F:
                res_r = r
                res_a = a
                res_b = b
print int(res_a + res_b), int(res_b)

Submission status: Wrong Answer

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:x[1])[-1])

Submission status: Wrong Answer

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(31):
      for di in range(31):
        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: Wrong Answer

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(31):
      for di in range(31):
        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:x[1])[-1])

Submission status: Wrong Answer

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(31):
      for di in range(31):
        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:x[1])[-1])

Submission status: Wrong Answer

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

ans_water, ans_sugar = 1, 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: Wrong Answer

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
ans_syokuen = 0
ans_mizu = 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: Wrong Answer

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

syokuen=[]

if a == 1 or b == 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=[]
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
ans_syokuen = 0
ans_mizu = 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: Wrong Answer

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: Wrong Answer

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
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: Wrong Answer

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*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: Wrong Answer

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*min(((F-water-C*c)//D),(water*E/100-C*c)//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
            c += 1
        b += 1
    a += 1

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

Submission status: Wrong Answer

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:
        c = 0
        while F-100*(A*a+B*b) >= C*c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//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
            c += 1
        b += 1
    a += 1

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

Submission status: Wrong Answer

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:
        c = 0
        while F-100*(A*a+B*b) > C*c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//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
            c += 1
        b += 1
    a += 1

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

Submission status: Wrong Answer

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

ans_con = 0
max_con = E/(100+E)*100

a = -1
while F > 100*A*a:
    b = 0
    while F-100*A*a > 100*B*b:
        c = 0
        while F-100*(A*a+B*b) > C*c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//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
            c += 1
        b += 1
    a += 1

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

Submission status: Wrong Answer

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

ans_con = 0
max_con = E/(100+E)*100

a = 0
while F > 100*A*a:
    b = 0
    while F-100*A*a > 100*B*b:
        c = 0
        while F-100*(A*a+B*b) > C*c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//D)
            mass = water + sugar
            if mass != 0:
                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: Wrong Answer

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

ans_con = 0
max_con = E/(100+E)*100

a = 0
while F > 100*A*a:
    b = 0
    while F-100*A*a > 100*B*b:
        c = 0
        while F-100*(A*a+B*b) > C*c and c <= 30:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//D, 30)
            mass = water + sugar
            if mass == 0:
                break
            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))