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: Runtime Error

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

s=[]
w=[]

max = 0
ans = []
for i in range(s_max//c+1):
    for j in range(s_max//d+1):
        if c*i + d*j <= s_max:
            s.append(c*i + d*j)

for i in range(w_max//a+1):
    for j in range(w_max//b+1):
        if 0<a*i + b*j <= w_max:
            w.append(a*i + b*j)

for i in range(len(s)):
    for j in range(len(w)):
        if s[i]/(w[j]*100+s[i])<=e/(e+100) and s[i]/(w[j]*100+s[i])>max:
            max = s[i]/(w[j]*100+s[i])
            ans = [w[j]*100+s[i],s[i]]

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

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int,input().split())
answer_number = [0,0,0,0]
answer_max = 0
for i in range((F/(100*A))+1):
  for j in range(((F-100*A*i)/(100*B))+1):
    if i==0 and j ==0: continue
    for k in range(((F-100*A*i-100*B*j)/C)+1):
      for l in range(((F-100*A*i-100*B*j-C*k)/D)+1):
        if (C*k+D*l)/(A*i+B*j) <= E:
          if (C*k+D*l)/(A*i+B*j) > answer_max:
            answer_max = (C*k+D*l)/(A*i+B*j)      #### k
            answer_number = [i,j,k,l]
if answer_number == [0,0,0,0]: print(0,0)
else:
  print(C*answer_number[2]+D*answer_number[3]+100*(A*answer_number[0]+B*answer_number[1]), C*answer_number[2]+D*answer_number[3])

Submission status: Runtime Error

Solution code:
import math

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

highest = 0
sugarwater = 0
maxsugar = 0
for aa in range(math.ceil(f / (100 * a))):
    for cc in range(math.ceil(f / c)):
        for bb in range(math.ceil(f / (100 * b))):
            for dd in range(math.ceil(f / d)):
                sugar = cc * c + dd * d
                water = 100 * (aa * a + bb * b)
                if (
                    sugar == 0
                    or water == 0
                    or sugar / (water / 100) > e
                    or water + sugar > f
                ):
                    continue
                density = 100 * sugar / (water + sugar)
                if density > highest:
                    highest = density
                    sugarwater = sugar + water
                    maxsugar = sugar
print(f"{sugarwater} {maxsugar}")

Submission status: Runtime Error

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

rmax=0
for a100 in range(0,f+1,100*a):
   for b100 in range(0,f-a100+1,100*b):
#   for b100 in range(0,f+1,100*b):
        if a100+b100>0:
            fcd=f-a100-b100
            for ci in range(0,fcd+1,c):
                for di in range(0,fcd+1,d):
                    if a100+b100+ci+di <=f:
                        if (a100+b100)/100*e>=ci+di:
                            if rmax<(ci+di)/(a100+b100):
                                rmax=(ci+di)/(a100+b100)
                                rab=a100+b100+ci+di
                                rcd=ci+di
print(rab,rcd)

Submission status: Runtime Error

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

rmax=0
for a100 in range(0,f+1,100*a):
#    for b100 in range(0,f-a100+1,100):
    for b100 in range(0,f+1,100*b):
        if a100+b100>0:
            fcd=f-a100-b100
            for ci in range(0,fcd+1,c):
                for di in range(0,fcd+1,d):
                    if a100+b100+ci+di <=f:
                        if (a100+b100)//100*e>=ci+di:
                            if rmax<(ci+di)/(a100+b100):
                                rmax=(ci+di)/(a100+b100)
                                rab=a100+b100+ci+di
                                rcd=ci+di
print(rab,rcd)

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    A, B, C, D, E, F = map(int, input().split())
    waters = set()
    for i in range(0, F, A):
        for j in range(0, F, B):
            ij = i * 100 + j * 100
            if ij > F:
                break
            waters.add(ij)
    sugers = set()
    for i in range(0, F, C):
        for j in range(0, F, D):
            ij = i + j
            if ij > F:
                break
            sugers.add(ij)
    ans_water = 0
    ans_suger = 0
    ans = 0
    for water in waters:
        for suger in sugers:
            if water + suger == 0:
                continue
            if water + suger > F:
                continue
            if 100 * suger > E * water:
                continue
            if 100 * suger / (water + suger) > ans:
                ans = 100 * suger / (water + suger)
                ans_water = water
                ans_suger = suger
    if ans_suger == 0:
        raise ValueError
        if A ** 100 <= F:
            print(A*100, 0)
        elif B * 100 <= F:
            print(B*100, 0)
        else:
            print(0, 0)
    else:
        print(ans_water+ans_suger, ans_suger)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    A, B, C, D, E, F = map(int, input().split())
    waters = set()
    for i in range(0, F, A):
        for j in range(0, F, B):
            ij = i * 100 + j * 100
            if ij > F:
                break
            waters.add(ij)
    sugers = set()
    for i in range(0, F, C):
        for j in range(0, F, D):
            ij = i + j
            if ij > F:
                break
            sugers.add(ij)
    ans_water = 0
    ans_suger = 0
    ans = 0
    for water in waters:
        for suger in sugers:
            if water + suger == 0:
                continue
            if water + suger > F:
                continue
            if 100 * suger > E * water:
                continue
            if 100 * suger / (water + suger) > ans:
                ans = 100 * suger / (water + suger)
                ans_water = water
                ans_suger = suger
    if ans_suger = 0:
        if A ** 100 <= F:
            print(A*100, 0)
        elif B * 100 <= F:
            print(B*100, 0)
        else:
            print(0, 0)
    else:
        print(ans_water+ans_suger, ans_suger)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int,input().split())
X = []
Y = []
res = 0
for i in range(f+1):
    for j in range(f+1):
        x = 100*a*i+100*b*j
        y = c*i+d*j
        if x > f and y > f:break
        X.append(x)
        Y.append(y)
def ok(x,y):
    return (x//100)*e >= y and x+y <=f
cnt = 0
X.sort()
Y.sort()
for x in X:
    for y in Y:
        if x+y > f:break
        
        if ok(x,y):
          
            if x+y == 0:continue
            if res < 100*y/(x+y):
                res = 100*y/(x+y)
                ansx = x
                ansy = y
        cnt +=1
print(ansx+ansy,ansy)

Submission status: Runtime Error

Solution code:
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
A = int(X[0])
B = int(X[1])
C = int(X[2])
D = int(X[3])
E = int(X[4])
F = int(X[5])

Water = 0
Sugar = 0



x = int(F/(100*A))
H = 0
for i in range(x+1):
    y = int((F-i * 100 * A)/100 * B)
    for j in range(y+1):
        Water = i * 100*A + j * 100 * B
        if ((Water > 0) and (Water < F )) == True:
            ISugar = Water * E/100
            z = int(ISugar/C)
            G = 0
            for k in range(z+1):
                w = int((ISugar - k * C)/D)                
                for l in range(w+1):
                    Sugar = k *C + l * D
                    if ((Sugar >= G) and (F >= Water + Sugar)) == True:
                        G = Sugar
                        Conc = 100*Sugar/(Water + Sugar)
            Sugar = G
            if  Conc >H:
                H = Conc
                Mass = Water + Sugar
                I = Sugar
		
print(Mass, I)

Submission status: Runtime Error

Solution code:
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
A = int(X[0])
B = int(X[1])
C = int(X[2])
D = int(X[3])
E = int(X[4])
F = int(X[5])

Water = 0
Sugar = 0


Satconc = 100 * E/(100+E)

x = int(F/(100*A))
H = 0
for i in range(x+1):
    y = int((F-i * 100 * A)/100 * B)
    for j in range(y+1):
        Water = i * 100*A + j * 100 * B
        if ((Water > 0) and (Water < F )) == True:
            ISugar = Water * E/100
            z = int(ISugar/C)
            G = 0
            for k in range(z+1):
                w = int((ISugar - k * C)/D)
                
                for l in range(w+1):
                    Sugar = k *C + l * D
                    if ((Sugar > G) and (F >= Water + Sugar)) == True:
                        G = Sugar
                        Conc = 100*Sugar/(Water + Sugar)

            Sugar = G
            if  Conc >H:
                H = Conc
                Mass = Water + Sugar
                I = Sugar
		
print(Mass, I)

Submission status: Runtime Error

Solution code:
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
A = int(X[0])
B = int(X[1])
C = int(X[2])
D = int(X[3])
E = int(X[4])
F = int(X[5])

Water = 0
Sugar = 0
if Water + Sugar == 0:
  Conc = 0
else:
  Conc = 100 * Sugar/(Water + Sugar)

Satconc = 100 * E/(100+E)

x = int(F/(100*A))
H = 0
for i in range(x+1):
    y = int((F-i * 100 * A)/100 * B)
    for j in range(y+1):
        Water = i * 100*A + j * 100 * B
        if ((Water > 0) and (Water < F )) == True:
            ISugar = Water * E/100
            z = int(ISugar/C)
            G = 0
            for k in range(z+1):
                w = int((ISugar - k * C)/D)
                
                for l in range(w+1):
                    Sugar = k *C + l * D
                    if ((Sugar > G) and (F >= Water + Sugar)) == True:
                        G = Sugar
                        Conc = 100*Sugar/(Water + Sugar)

            Sugar = G
            if  Conc >H:
                H = Conc
                Mass = Water + Sugar
                I = Sugar
		
print(Mass, I)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
sug, dif2 = 0, 100
s = {}
wat1, wat2 = 100*a, 100*b
cap1, cap2 = a*e, b*e
for i in range(1,f//wat1+1):
    for j in range(f//wat2+1):
        if (wat1+cap1)*i+(wat2+cap2)*j<=f:
            s[cap1*i+cap2*j] = wat1*i+wat2*j
if s == {}:
    dif1 = f - wat1
    for i in range(10):
        for j in range(10):
            if 0<=(f-wat1) - (c*i+d*j)<dif1:
                dif1 = (f-wat1)-(c*i+d*j)
                sug3 = c*i+d*j
    print(wat1+sug3, sug3)
    exit(0)
print(wat,sug1, sug2)
for i in s.keys():
    for j in range(i//c+1):
        for k in range(i//d+1):
            if 0<=i-(c*j+d*k)<dif2:
                dif2 = i-(c*j+d*k)
                wat,sug1,sug2 = s[i],j,k
print(wat,sug1, sug2)
print(c*sug1+d*sug2+wat, c*sug1+d*sug2)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
sug, dif = 0, 100
s = {}
wat1, wat2 = 100*a, 100*b
cap1, cap2 = a*e, b*e

for i in range(1,f//wat1+1):
    for j in range(f//wat2+1):
        if (wat1+cap1)*i+(wat2+cap2)*j<=f:
            s[cap1*i+cap2*j] = wat1*i+wat2*j
for i in s.keys():
    for j in range(i//c+1):
        for k in range(i//d+1):
            if 0<=i-(c*j+d*k)<dif:
                dif = i-(c*j+d*k)
                wat,sug1,sug2 = s[i],j,k
print(c*sug1+d*sug2+wat, c*sug1+d*sug2)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
sug = 0
wat = 100*a
cap = a*e
for i in range(100):
    for j in range(100):
        if (c*i+d*j<=cap) and (wat+c*i+d*j)<=f:
            sug = max(c*i+j*d, sug)
print(wat1+sug, sug)

Submission status: Runtime Error

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

water = set()
sugar = set()

s = 0
a = 0
b = 0

for i in range(30):
    for j in range(30-i):
        if 100*A*i+100*B*j <= F:
            water.add(100*A*i+100*B*j)

water.remove(0)

for i in range(3000):
    for j in range(3000-i):
        if C*i+D*j <= F:
            sugar.add(C*i+D*j)

sugar.remove(0)

WATER = list(water)
SUGAR = list(sugar)

for i in WATER:
    for j in SUGAR:
        if (j <= i*E/100) and (i+j <= F):
            if s == 0:
                s = 100*j /(i + j)
                a = i
                b = j
            else:
                if s < 100*j /(i + j):
                    s = 100*j /(i + j)
                    a = i
                    b = j

if a = 0 and b = 0:
    print(100*A,0)
else:
    print(a+b,b)

Submission status: Runtime Error

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

water = set()
sugar = set()

s = 0

for i in range(30):
    for j in range(30-i):
        if 100*A*i+100*B*j <= F:
            water.add(100*A*i+100*B*j)

water.remove(0)

for i in range(3000):
    for j in range(3000-i):
        if C*i+D*j <= F:
            sugar.add(C*i+D*j)

sugar.remove(0)

WATER = list(water)
SUGAR = list(sugar)

for i in WATER:
    for j in SUGAR:
        if (j <= i*E/100) and (i+j <= F):
            if s == 0:
                s = 100*j /(i + j)
                a = i
                b = j
            else:
                if s < 100*j /(i + j):
                    s = 100*j /(i + j)
                    a = i
                    b = j

print(a+b,b)

Submission status: Runtime Error

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

# 作れるか判定
def check(goal,ac,bd):
    flag = 0
    for x in range(int(goal//ac)+1):
            if (goal-ac*x)%bd == 0 : flag = 1 ; break
    return flag

# 水W、砂糖Sをまわす
anss = []
for w in range(100,f+1,100):
    for s in range(1,f-w+1):
        if check(w,100*a,100*b) and check(s,c,d) and s<=((w*e)/100):
            conc = 100*s/(w+s) # concentration
            anss.append([conc,w,s])

anss.sort(reverse=1)
w,s = anss[0][1],anss[0][2]
print(w+s,s)

Submission status: Runtime Error

Solution code:
from operator import itemgetter

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

for a in range(31):
    for b in range(31):
        for c in range(71)       #範囲の指定がよくわからない
            for d in range(71):  #範囲の指定がよくわからない
                w = 100*A*a+100*B*b #水の質量
                s = C*c+D*d        #砂糖の質量
                if w == 0  or w + s >= F: #ダメな条件 砂糖０はあり得る
                    break
                else:
                    if s/(w+s) <= E/(100 + E):
                        ans = 100 * s/(w+s)
                        X.append([ans,w + s, s])
X = sorted(X,key=itemgetter(0),reverse = True) 
#print(X)
print(X[0][1],X[0][2])

Submission status: Runtime Error

Solution code:
from operator import itemgetter

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

for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                w = 100*A*a+100*B*b #砂糖水の質量
                s = C*c+D*d        #砂糖の質量
                if w == 0 or s == 0 or w + s >= F: #ダメな条件
                    break
                else:
                    if s/(w+s) <= E/(100 + E):
                        ans = 100 * s/(w+s)
                        X.append([ans,w + s, s])
X = sorted(X,key=itemgetter(0),reverse = True) 
print(X[0][1],X[0][2])

Submission status: Runtime Error

Solution code:
from operator import itemgetter

A, B, C, D, E, F = list(map(int,input().split()))
X = []
ans = 1000
for a in range(31):
    for b in range(31):
        for c in range(31):
            for d in range(31):
                w = 100*A*a+100*B*b #砂糖水の質量
                s = C*c+D*d        #砂糖の質量
                if w == 0 or s == 0 or w + s >= F: #ダメな条件
                    break
                else:
                    if s/(w+s) <= E/(100 + E):
                        ans = 100 * s/(w+s)
                        X.append([ans,w + s, s])
X = sorted(X,key=itemgetter(0),reverse = True) 
print(X[0][1],X[0][2])

Submission status: Runtime Error

Solution code:
from operator import itemgetter

A, B, C, D, E, F = list(map(int,input().split()))
X = []
ans = 1000
for a in range(31):
    for b in range(31):
        for c in range(31):
            for d in range(31):
                w = 100*A*a+100*B*b #砂糖水の質量
                s = C*c+D*d        #砂糖の質量
                if w == 0:
                    break
                if s == 0 :
                    break
                if w + s > F:
                    break
                else:
                    if w/100 * E >= s:
                        ans = 100 * s/(w+s)
                        X.append([ans,w + s, s])
X = sorted(X,key=itemgetter(0),reverse = True) 
print(X[0][1],X[0][2])

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
kouho = []
for i in range(f // a + 1):
    for j in range(f // b + 1):
        water = 100 * (a * i + b + j)
        if water > f:
            break
        if water == 0:
            break
        sugar_max = (a * i + b + j) * e
        for k in range(sugar_max // c + 1):
            for l in range(sugar_max // d + 1):
                sugar = c * k + d * l
                if water + sugar > f:
                    break
                if sugar > sugar_max:
                    break
                density = (sugar / (water + sugar), water + sugar, sugar)
                kouho.append(density)
kouho.sort(reverse=True)
print(kouho[0][1], kouho[0][2])

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
kouho = []
for i in range(f // a + 1):
    for j in range(f // b + 1):
        water = 100 * (a * i + b + j)
        if water > f:
            break
        sugar_max = (a * i + b + j) * e
        for k in range(sugar_max // c + 1):
            for l in range(sugar_max // d + 1):
                sugar = c * k + d * l
                if water + sugar > f:
                    break
                if sugar > sugar_max:
                    break
                if water + sugar == 0:
                    continue
                density = (sugar / (water + sugar), water + sugar, sugar)
                kouho.append(density)
kouho.sort(reverse=True)
print(kouho[0][1], kouho[0][2])

Submission status: Runtime Error

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


ab = []

for i in range(f):
    for j in range(f):
       
        x = a*100*i+b*100*j
        if x > f:
            continue
        
        else:
            ab.append(x)
    

cd = []

for i in range(f):
    for j in range(f):
        x = c*i+d*j
        if x > f:
           continue
       
        else:
            cd.append(x)
    
ab = set(ab)
cd = set(cd)

max_g = []
max_concentration = 0

for water in ab:
    for suger in cd:
        if water == 0 and suger == 0:
            continue
        if water + suger > f:
            continue
        if suger > (e/100)*water:
            continue
        
        concentration = (100*suger) / water + suger
        
        if concentration > max_concentration:
            max_concentration = concentration
            max_g = [water,suger]
            
print(sum(max_g), max_g[1])

Submission status: Runtime Error

Solution code:
from decimal import Decimal as D
mi1,mi2,sa1,sa2,houwa,lim=map(int,input().split())
slim=houwa*lim/(100+houwa)
ws=set(mi1*i+mi2*j for i in range(lim//(100*mi1)+1) for j in range(lim//(100*mi2)+2) if 100*(mi1*i+mi2*j)<=lim)
ss=set(sa1*i+sa2*j for i in range(slim//sa1+1) for j in range(slim//sa2+2) if (sa1*i+sa2*j)<=slim)
ans=D("0")
iw,isa=mi1*100,0
for s in ss:
  for w in ws:
    if s>houwa*w or w==0:continue
    if ans<D(str(10000*s))/D(str(s+100*w)) and s+100*w<=lim:
      ans=D(str(10000*s))/D(str(s+100*w))
      isa,iw=s,w
print(100*iw+isa,isa)

Submission status: Runtime Error

Solution code:
from decilmal import Decimal as D
mi1,mi2,sa1,sa2,houwa,lim=map(int,input().split())
slim=lim*houwa//100
ws=set(mi1*i+mi2*j for i in range(lim//(100*mi1)+2) for j in range(lim//(100*mi2)+2) if 100*(mi1*i+mi2*j)<=lim)
ss=set(sa1*i+sa2*j for i in range(slim//sa1+2) for j in range(slim//sa2+2) if (sa1*i+sa2*j)<=slim)
ans=D("0")
iw,isa=mi1*100,0
for s in ss:
  for w in ws:
    if s>houwa*w or s==w==0:continue
    if ans<D(str(10000*s))/D(str(s+100*w)) and s+100*w<=lim:
      ans=D(str(10000*s))/D(str(s+100*w))
      isa,iw=s,w
print(100*iw+isa,isa)

Submission status: Runtime Error

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

water=set()#入れる可能性のある水の量O(A*B)
sugar=set()#入れる可能性のある佐藤の量O(C*D)

for i in range(31):
    for j in range(31):
        water.add(100*i*a+100*j*b)

for i in range(1501):
    for j in range(1501):
        sugar.add(c*i+d*j)
water=sorted(list(water))
#print(water)
sugar=sorted(list(sugar))
#print(sugar)
ans=0
sumans=0
for i in range(1,len(water)):
    for j in range(len(sugar)):
        if water[i]+sugar[j]<=f and (sugar[j]/(water[i]//100))<=e:
            if ans<(100*sugar[j])//(water[i]+sugar[j]):
                #print(sugar[j],water[j])
                ans=(100*sugar[j])/(water[i]+sugar[j])
                sugarans=sugar[j]
                sumans=water[i]+sugar[j]
print(sumans,sugarans)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
n=F//(100*A)
m=int((F/(100+E))*E/C)
#print(n,m)
a=0
b=0
c=0
for i in range(n+1):
  for j in range(F//(100*B)+1):
    for k in range(m+1):
      for l in range(int((F/(100+E))*E/D)+1):
        if((n+1-i>0 or j>0) and (i*A+j*B)*E>=k*C+l*D and 100*(A*i+B*j)+k*C+l*D<=F):
          if((k*C+l*D)/(100*(A*i+B*j)+k*C+l*D)>=c):
            a=100*(A*i+B*j)+k*C+l*D
            b=k*C+l*D
            c=(k*C+l*D)/(100*(A*i+B*j)+k*C+l*D)
            #print(c)
print(a,b)

Submission status: Runtime Error

Solution code:
S = input().split(" ")
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
E = int(S[4])
F = int(S[5])

def calculate(a, b, c, d, e, f):
    result = []

    for x in range(math.ceil(f / (a * 100))):
        for y in range(math.ceil(f / (b * 100))):
            result.append([x, y])

    maxNondu = 0
    finalResult = []
    for res in result:
        m = 0
        waterValue = res[0] * 100 * a + res[1] * 100 * b

        while waterValue + m <= f:
            n = 0
            sugerValue = m * c + n * d
            while waterValue + sugerValue <= F:
                sugerValue = m * c + n * d
                if math.ceil(sugerValue / e) * 100 <= waterValue:
                    if sugerValue + waterValue > 0:
                        nondu = sugerValue * 100 / (sugerValue + waterValue)
                        if nondu > maxNondu:
                            maxNondu = nondu

                            finalResult = [waterValue + sugerValue, sugerValue]

                n = n + 1
            m = m + 1

    if len(finalResult) == 0:
        print("{} {}".format(a,0))
    else:
        print("{} {}".format(finalResult[0],finalResult[1]))


calculate(A, B, C, D, E, F)

Submission status: Runtime Error

Solution code:
import math

S = input().split(" ")
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
E = int(S[4])
F = int(S[5])

def calculate(a, b, c, d, e, f):
    result = []

    for x in range(math.ceil(f / (a * 100))):
        for y in range(math.ceil(f / (b * 100))):
            result.append([x, y])

    maxNondu = 0
    finalResult = []
    for res in result:
        m = 0
        waterValue = res[0] * 100 * a + res[1] * 100 * b
        while waterValue + m <= f:
            n = 0
            sugerValue = m * c + n * d
            while waterValue + sugerValue <= F:
                sugerValue = m * c + n * d
                if math.ceil(sugerValue / e) * 100 <= waterValue:
                    if sugerValue + waterValue > 0:
                        nondu = sugerValue * 100 / (sugerValue + waterValue)
                        if nondu > maxNondu:
                            maxNondu = nondu

                            finalResult = [waterValue + sugerValue, sugerValue]

                n = n + 1
            m = m + 1
    print("{} {}".format(finalResult[0],finalResult[1]))


calculate(A, B, C, D, E, F)

Submission status: Runtime Error

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

indxmax=0.0
wmax=0
emax=0
elmt=100*e/(100+e)
a31=int(f/100/a)+1
b31=int(f/100/b)+1
c31=int(f/c)+1
for ai in range(a31):
    for bi in range(b31):
        w=100*a*ai+100*b*bi
#        print("a,b:",ai,bi,w)
        if w<=f and w>0:
#            c31=int(w/100*e/c)+1
#            c31=min(int(w/100*e/c)+1,31)
#            d31=int(w/100*e/d)+1
            for ci in range(c31):
#                di=int((w/100*e-c*ci)/d+10**(-10))
                dii=max(0,int((w/100*e-c*ci)/d))
#                for di in range(d31):
                for di in range(dii-1,dii+2):
                    diii=max(0,di)
#                    indx=(c*ci+d*diii)*100/w
                    indx=100*(c*ci+d*diii)/(w+c*ci+d*diii)
                    if indxmax<indx and elmt-indx>=0.0 and w+c*ci+d*diii<=f:
                        wmax=int(w+c*ci+d*diii)
                        indxmax=indx 
                        emax=int(c*ci+d*diii)
#                    print("c,d",ci,di,emax,wmax,diii)
if wmax>0:
    print(wmax,emax)
else:
    print(100*a,emax

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math

A, B, C, D, E, F = (int(x) for x in input().strip().split())

max_A = F // (A * 100) #操作１を実行できる回数
max_B = F // (B * 100) #操作２を実行できる回数

ans_a, ans_b, ans_c, ans_d, ans_per = 0, 0, 0, 0, 0
for i in range(max_A + 1):
    for j in range(max_B + 1):
        if i == 0 and j == 0:
            j += 1
        max_melt = E * (A * i + B * j)
        rem = F - (100 * A * i + 100 * B * j) #容器の残り
        if rem < C and rem < D:
            break
        suger = 0
        for x in range(math.ceil(max_melt / C) + 1):
            for y in range(math.ceil(max_melt / D) + 1):
                if x * C + y * D > max_melt or  x * C + y * D > rem:
                    break
                if x * C + y * D > suger:
                    suger = x * C + y * D
                    c, d = x, y

        per = 100 * (c * C + d * D) / (100 * (i * A + j * B) + c * C + d * D)
        if per > ans_per:
            ans_per = per
            ans_a, ans_b, ans_c, ans_d = i, j, c, d

print(100 * ans_a * A + 100 * ans_b * B + ans_c * C + ans_d * D, end=" ")
print(ans_c * C + ans_d * D)

Submission status: Runtime Error

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

# 100A,100B の水
for a in range(1 + F // 100):
    for b in range(1 + F // 100):
        water = 100 * (a * A + b * B)
        if 0 < water <= F:
            W.append(water)

# c,d の砂糖
for c in range(1 + F // C):
    for d in range(1 + F // D):
        sugar = c * C + d * D
        if 0 < sugar <= F:
            S.append(sugar)

W = list(set(W))
S = list(set(S))

x = -1
for w in W:
    for s in S:
        if w + s <= F:
            sol = 100 * s / w
            if x < sol <= E:
                x = sol
                X, Y = w + s, s

print(X,Y)

Submission status: Runtime Error

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

# 100A,100B の水
for a in range(1 + F // 100):
    for b in range(1 + F // 100):
        water = 100 * (a * A + b * B)
        if 0 < water <= F:
            W.append(water)

# c,d の砂糖
for c in range(1 + F // C):
    for d in range(1 + F // D):
        sugar = c * C + d * D
        if 0 < sugar <= F:
            S.append(sugar)

W = list(set(W))
S = list(set(S))

x = -1
for w in W:
    for s in S:
        if w + s <= F:
            sol = 100 * s / w
            if x <= sol <= E:
                x = sol
                X, Y = w + s, s

print(X,Y)

Submission status: Runtime Error

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

# 100A,100B の水
for a in range(1 + F // 100):
    for b in range(1 + F // 100):
        water = 100 * (a * A + b * B)
        if 0 < water <= F:
            W.append(water)

# c,d の砂糖
for c in range(1 + F // C):
    for d in range(1 + F // D):
        sugar = c * C + d * D
        if 0 < sugar <= F:
            S.append(sugar)

W = list(set(W))
S = list(set(S))

x = 0
for w in W:
    for s in S:
        if w + s <= F:
            sol = 100 * s / w
            if x < sol <= E:
                x = sol
                X, Y = w + s, s

print(X,Y)

Submission status: Runtime Error

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

# 100A,100B の水
for a in range(1 + F // 100):
    for b in range(1 + F // 100):
        water = 100 * (a * A + b * B)
        if 0 < water <= F:
            M.append(water)

# c,d の砂糖
for c in range(1 + F // C):
    for d in range(1 + F // D):
        sugar = c * C + d * D
        if 0 < sugar <= F:
            S.append(sugar)

M=list(set(M))
S=list(set(S))
# M.sort()
# S.sort()
#print(M,S)

x = 0
for m in M:
  for s in S:
    if m != 0 and m + s <= F:
        sol = 100 * s / m
        if sol > x and sol <= E:
            x = sol
            X, Y = m + s, s

print(X,Y)

Submission status: Runtime Error

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

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

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

M=list(set(M))
S=list(set(S))
M.sort()
S.sort()

x = 0
for m in M:
  for s in S:
    if m != 0 and m + s <= F:
        sol = 100 * s / m
        if sol > x and sol <= E:
            x = sol
            X, Y = m + s, s

print(X,Y)