Problem:


Score : 300 points

Problem Statement

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

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

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

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

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

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

Snuke will make sugar water with the highest possible density.

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

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

Constraints

1 \leq A < B \leq 30

1 \leq C < D \leq 30

1 \leq E \leq 100

100A \leq F \leq 3 000

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

Inputs

Input is given from Standard Input in the following format:

A B C D E F

Outputs

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

Sample Input 1

1 2 10 20 15 200

Sample Output 1

110 10

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

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

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

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

Sample Input 2

1 2 1 2 100 1000

Sample Output 2

200 100

There are other acceptable outputs, such as:

400 200

However, the output below is not acceptable:

300 150

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

Sample Input 3

17 19 22 26 55 2802

Sample Output 3

2634 934



Sample input:
1 2 10 20 15 200


Sample output:
110 10

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
for i in range(f//100+1):
    for j in range(f//100+1):
        x=100*a*i+100*b*j
        if x<=f:
            w.append(x)
w=list(set(w))

for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
s=list(set(s))
s.sort()
max_con=0
ans=ans_2=0
for i in w:
    for j in s:
        if e*(i//100)<j:
            continue
        elif f<i+j:
            continue
        elif i==0 and j==0:
            continue
        else:
            con=Fraction(100*j,i+j)
            if max_con<con:
                max_con=con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(f//100+1):
    for j in range(f//100+1):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))

for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
max_con=0
ans=ans_2=0
for i in w:
    for j in s:
        if e*(i//100)<j:
            continue
        elif f<i+j:
            continue
        else:
            con=Fraction(100*j,i+j)
            if max_con<con:
                max_con=con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(f//100+1):
    for j in range(f//100+1):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))

for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
max_con=0
ans=ans_2=0
for i in w:
    for j in s:
        if e*(i//100)<j:
            continue
        elif f<i+y:
            continue
        else:
            con=Fraction(100*j,i+j)
            if max_con<con:
                max_con=con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(f//100+1):
    for j in range(f//100+1):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))

for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
max_con=0
ans=ans_2=0
for i in w:
    for j in s:
        if e*(i//100)<j:
            continue
        elif f<i+y:
            continue
        else:
            con=Fraction(100*j,i+j)
            if max_con<con:
                max=con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))

for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=0
con=1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100):
            max_con=Fraction(100*j,i+j)
            if con<=max_con:
                con=max_con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))

for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=0
con=-1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100) and j/i:
            ans,ans_2,con=i+j,j,j/i
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))
for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=1
con=-1
for i in w:
    for j in s:
        if i+j<=f+1 and j<=e*(i//100):
            max_con=Fraction(100*j,i+j)
            if con<=max_con:
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))
for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=1
con=-1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100):
            max_con=Fraction(100*j,i+j)
            if con<=max_con:
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))

for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=0
con=-1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100):
            max_con=Fraction=100*j/(i+j)
            if con<=max_con:
                con=max_con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))

for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=0
con=1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100):
            max_con=Fraction=100*j//(i+j)
            if con<max_con:
                con=max_con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))

for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=0
con=1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100):
            max_con=Fraction=100*j/(i+j)
            if con<max_con:
                con=max_con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))

for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=0
con=1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100):
            max_con=Fraction=100*j/(i+j)
            if con<=max_con:
                con=max_con
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))
for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=0
con=1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100):
            max_con=Fraction(100*j,i+j)
            if con<=max_con:
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))
for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
ans=ans_2=0
con=1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100):
            max_con=(100*j)/(i+j)
            if con<=max_con:
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=s=[]
from fractions import Fraction
import math
for i in range(math.ceil(f/a)):
    for j in range(math.ceil(f/b)):
        x=100*a*i+100*b*j
        if 0<x and x<=f:
            w.append(x)
w=list(set(w))
print(w)
for i in range(math.ceil(f/c)):
    for j in range(math.ceil(f/d)):
        y=i*c+j*d
        if 0<y and y<=f:
            s.append(y)
s=list(set(s))
s.sort()
print(s)
ans=ans_2=0
con=1
for i in w:
    for j in s:
        if i+j<=f and j<=e*(i//100):
            max_con=(100*j)/(i+j)
            if con<=max_con:
                ans=i+j
                ans_2=j
print(ans,ans_2)

Submission status: Wrong Answer

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

W,S = [],[0]
limW,limS = int(F*100/(100+E)),int(F*E/(100+E))

for ai in range(ceil(limW/A)):
    for bi in range(ceil(limW/B+1)):
        w = 100*A*ai+100*B*bi
        if w <= limW and 0 < w and w not in W:
            W.append(w)
for ci in range(ceil(limS/C)):
    for di in range(ceil(limS/D)):
        s = C*ci+D*di
        if s <= limS and 0 < s and s not in S:
            S.append(s)

AnsWS,AnsS,r = 0,0,-1
for wi in W:
    for si in S:
        if r < si/wi and si <= E*(wi//100) and (wi+si) <= F:
            AnsWS,AnsS,r = wi+si,si,si/wi

print(AnsWS,AnsS)

Submission status: Wrong Answer

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

W,S = [],[]
limW,limS = int(F*100/(100+E)),int(F*E/(100+E))

for ai in range(ceil(limW/A)):
    for bi in range(ceil(limW/B+1)):
        w = 100*A*ai+100*B*bi
        if w <= limW and 0 < w and w not in W:
            W.append(w)
for ci in range(ceil(limS/C)):
    for di in range(ceil(limS/D)):
        s = C*ci+D*di
        if s <= limS and 0 < s and s not in S:
            S.append(s)

AnsWS,AnsS,r = 0,0,0  
for wi in W:
    for si in S:
        if r < si/wi and si <= E*(wi//100) and (wi+si) <= F:
            AnsWS,AnsS,r = wi+si,si,si/wi

print(AnsWS,AnsS)

Submission status: Wrong Answer

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

sugar = []
for i in range(f//100+1):
    for j in range(f//100+1):
        y = i*c + j*d
        if y <= f:
            sugar.append(y)

water = []
for i in range(0, f+1):
    for j in range(0, f+1):
        x = i*a*100 + j*b*100
        if x <= f:
            water.append(x)
max_concentration = 0
ans1, ans2 = 0, 0
for x in water:
    for y in sugar:
        if x == 0 and y == 0:
            continue
        elif e * (x // 100) < y:
            continue
        elif x + y > f:
            continue
        else:
            concentration = (100 * y) / (x+y)
            if max_concentration <= concentration:
                max_concentration = concentration
                ans1 = x+y
                ans2 = y
print("{} {}".format(ans1, ans2))

Submission status: Wrong Answer

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

sugar = []
for i in range(f//100+1):
    for j in range(f//100+1):
        y = i*c + j*d
        if y <= f:
            sugar.append(y)

water = []
for i in range(0, f+1):
    for j in range(0, f+1):
        x = i*a*100 + j*b*100
        if x <= f:
            water.append(x)
max_concentration = 0
for x in water:
    for y in sugar:
        if x == 0 and y == 0:
            continue
        elif e * (x // 100) < y:
            continue
        elif x + y > f:
            continue
        else:
            concentration = (100 * y) / (x+y)
            if max_concentration <= concentration:
                max_concentration = concentration
                ans1 = x+y
                ans2 = y
print("{} {}".format(ans1, ans2))

Submission status: Wrong Answer

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

sugar = []
for i in range(f//100+1):
    for j in range(f//100+1):
        y = i*c + j*d
        if y <= f:
            sugar.append(y)

water = []
for i in range(0, f+1):
    for j in range(0, f+1):
        x = i*a*100 + j*b*100
        if x <= f:
            water.append(x)
max_concentration = 0
for x in water:
    for y in sugar:
        if x == 0 and y == 0:
            continue
        elif e * (x // 100) < y:
            continue
        elif x + y > f:
            continue
        else:
            concentration = 100 * y / (x+y)
            if max_concentration <= concentration and concentration <= 100*(e/100) and x+y <= f:
                max_concentration = concentration
                ans1 = x+y
                ans2 = y
print("{} {}".format(ans1, ans2))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
for i in range(1, f + 1, 100 * a):
    for j in range(1, f - i + 1, 100 * b):
        y = min((i + j) * e // 100, f - i - j)
        for k in range(0, y + 1, c):
            for l in range(0, y - k + 1, d):
                concentration = 100 * (k + l) / (i + j + k + l)
                if max_concentration <= concentration:
                    max_concentration = concentration
                    res1 = i + j + k + l
                    res2 = k + l
print(str(res1) + ' ' + str(res2))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
res1 = 0
res2 = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f - i + 1, 100 * b):
        if i == 0 and j == 0:
            continue
        y = min((i + j) * e // 100, f - i - j)
        for k in range(0, y + 1, c):
            for l in range(0, y - k + 1, d):
                concentration = 100 * (k + l) / (i + j + k + l)
                if max_concentration < concentration:
                    max_concentration = concentration
                    res1 = i + j + k + l
                    res2 = k + l
print(str(res1) + ' ' + str(res2))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
x=[]
for i in range(int(f/100/a+0.9)):
    for j in range(int(f/100/b+0.9)):
        if (100*a*i+100*b*j)<= f:
            x.append(100*a*i+100*b*j)
y=[]
for i in range(int(f/c+0.9)):
    for j in range(int(f/d+0.9)):
        if (c*i+d*j)<= f:
            y.append(c*i+d*j)
del y[0]
p=e/(100+e)
maxp=0
mj=0
mi=0
for i in x:
    for j in y:
        if((i+j<=f) and (j/(i+j)<=p)):
            if(j/(i+j)>maxp):
                mj=j
                mi=i
                maxp=j/(i+j)
print(str(mj+mi)+" "+str(mj))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans=100
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        s=100*a*i+100*b*j
        if s==0:
            break
        for ii in range((f-100*a)//c+1):
            for jj in range((f-100*a)//d+1):
                t=c*ii+d*jj
                if t==0:
                    break
                u=(100*t)/(s+t)
                if s+t<=f and u==f:
                    print(str(s+t)+" "+str(t))
                    exit()
                if s+t<=f and u<f:
                    if ans>u:
                        ans=u
                        x,y=s,t
print(str(x+y)+" "+str(y))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans=100
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        s=100*a*i+100*b*j
        if s==0:
            break
        for ii in range((f-100*a)//c+1):
            for jj in range((f-100*a)//d+1):
                t=c*ii+d*jj
                if t==0:
                    break
                u=(100*t)/(s+t)
                if s+t<=f and u==f:
                    print(str(s+t)+" "+str(t))
                    exit()
                if s+t<=f and u<f:
                    if ans>u:
                        ans=u
                        x,y=s,t
print([ans,x,y])

Submission status: Wrong Answer

Solution code:

a,b,c,d,e,f=(int(i) for i in input().split())
w,s,num=set(),set(),0
ans=[0,0]
max_salt=int(e*f/((100+e)*1.0))
for i in range(((f-f%(a*100))//(a*100))+1):#//は切り捨て除算
    #Aの何倍が最適かを網羅的に走査
    for j in range(((f-f%(b*100))//(b*100))+1):
        if i*a*100+j*b*100<=f:
            w.add(i*a*100+j*b*100)
        else:
            break
for i in range((max_salt-max_salt%c)//c+1):
    for j in range((max_salt-max_salt%d)//d+1):
        if i*c+j*d<=max_salt:
            s.add(i*c+j*d)
        else:break

w2,s2=sorted(list(w)),sorted(list(s))
for i in w2:
    for j in s2:
        if 0<i+j<=f and e*i-100*j>=0 and (i+j)*num<j:
            num=j/((i+j)*1.0)
            ans[0]=i
            ans[1]=j
print(sum(ans),ans[1])

Submission status: Wrong Answer

Solution code:

Data=list(map(int,input().split()))
maximum=Data[4]/(100+Data[4])#最大濃度
ans1=ans=ans2=0
List1=[]
List2=[]

o_lim=int(1+Data[5]/(100*Data[0]))
l_lim=int(1+Data[5]/(100*Data[1]))

for x in range(o_lim):
    for y in range(l_lim):
        if x*Data[0]*100+y*Data[1]*100>Data[5]:break
        else:List1.append(x*Data[0]*100+y*Data[1]*100)
o_lim=int(1+Data[5]/(Data[2]))
l_lim=int(1+Data[5]/(Data[3]))
for x in range(o_lim):
    for y in range(l_lim):
        if x*Data[2]+y*Data[3]>Data[5]:break
        else:List2.append(x*Data[2]+y*Data[3])

for i in range(len(List1)):
    for j in range(len(List2)):
        temp1=List1[i]+List2[j]
        if temp1==0:continue
        if (temp1)<Data[5] and List2[j]/(temp1)<maximum and ans<List2[j]/(temp1):
            ans = List2[j]/(temp1)
            ans1=temp1
            ans2=List2[j]
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = (int(i) for i in input().split())
w,s,num,answer = set(),set(),0,[0,0]
for i in range((f-f%(a*100))//(a*100)+1):
	for j in range((f-f%(b*100))//(b*100)+1):
		if i*a*100+j*b*100 <= f:
			w.add(i*a*100+j*b*100)
		else:
			break
smax = int(e*f/((100+e)*1.0))
for i in range((smax-smax%c)//c+1):
	for j in range((smax-smax%d)//d+1):
		if i*c+j*d <= smax:
			s.add(i*c+j*d)
		else:
			break
w2,s2 = sorted(list(w))[::-1],sorted(list(s))[::-1]
for i in w2:
	for j in s2:
		if 0 < i+j <= f and e*i>=100*j and num<(j/((i+j)*1.0)):
			num =  j/((i+j)*1.0)
			answer = [i,j]
print(sum(answer),answer[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = (int(i) for i in input().split())
w,s,num,answer = set(),set(),0,[0,0]
for i in range((f-f%(a*100))//(a*100)+1):
	for j in range((f-f%(b*100))//(b*100)+1):
		if i*a*100+j*b*100 <= f:
			w.add(i*a*100+j*b*100)
		else:
			break
smax = e*f/((100+e)*1.0)
for i in range(int((smax-smax%c)//c)+1):
	for j in range(int((smax-smax%d)//d)+1):
		if i*c+j*d <= smax:
			s.add(i*c+j*d)
		else:
			break
w2,s2 = sorted(list(w))[::-1],sorted(list(s))[::-1]
for i in w2:
	for j in s2:
		if 0 < i+j <= f and e*i>=100*j and num<(j/((i+j)*1.0)):
			num =  j/((i+j)*1.0)
			answer = [i,j]
print(sum(answer),answer[1])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int, input().split())
mw,ms = 0,0
i_times = int(F/(100*A)) + 1
j_times = int(F/(100*B)) + 1
k_times = int(F/(C)) + 1
l_times = int(F/(D)) + 1
ideal = E/(100+E)
bf = 0
for i in range(0,i_times):
    for j in range(0,j_times):
        for k in range(0,k_times):
            for l in range(0,l_times):
                if not (k or l):
                    break
                w,s = 0,0
                w += i*A*100
                w += j*B*100
                s += k*C
                s += l*D
                if w + s > F:
                    break
                if s/(w+s) <= ideal and bf <= s/(w+s):
                    mw, ms = w,s
                    bf = s/(w+s)
print(mw+ms, ms)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int, input().split())
mw,ms = 0,0
i_times = int(F/(100*A)) + 1
j_times = int(F/(100*B)) + 1
k_times = int(F/(C)) + 1
l_times = int(F/(D)) + 1
ideal = E/(100+E)
bf = 0
for i in range(0,i_times):
    for j in range(0,j_times):
        for k in range(0,k_times):
            for l in range(0,l_times):
                if not (k or l):
                    break
                w,s = 0,0
                w += i*A*100
                w += j*B*100
                s += k*C
                s += l*D
                if w + s > F:
                    break
                if s/(w+s) <= ideal and bf < s/(w+s):
                    mw, ms = w,s
                    bf = s/(w+s)
print(mw+ms, ms)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int, input().split())
mw,ms = 0,0
i_times = int(F/(100*A)) + 1
j_times = int(F/(100*B)) + 1
k_times = int(F/(C)) + 1
l_times = int(F/(D)) + 1
ideal = (E/100)/2
bf = 0
for i in range(0,i_times):
    for j in range(0,j_times):
        for k in range(0,k_times):
            for l in range(0,l_times):
                if not (k or l):
                    break
                w,s = 0,0
                w += i*A*100
                w += j*B*100
                s += k*C
                s += l*D
                if w + s > F:
                    break
                if s/(w+s) <= ideal and bf < s/(w+s):
                    mw, ms = w,s
                    bf = s/(w+s)
print(mw+ms, ms)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
maxden = 0
amax = f //(a*100)
water=a*100
sugar=0
for i in range(amax+1):
  waterA = i*100*a
  res = f-waterA
  bmax = res // (b*100)
  for j in range(bmax+1):
    waterB = j*100*b
    waterS =waterA+waterB
    res = f-waterS
    cmax = res // c
    for k in range(cmax+1):
      sugarC = k*c
      res = f-waterS-sugarC
      dmax = res // d
      for l in range(dmax+1):
        sugarD = l*d
        sugarS = sugarC+sugarD
        if(sugarS+waterS==0):break
        den = (sugarS)*100/(sugarS+waterS)
        #if(den>49 and den<50.1):print(res-sugarD,waterA,waterB,sugarC,sugarD,den)
        if(den>maxden and ((den*(100+e))/100)<=(e)):
          maxden = den
          sugar = sugarS
          water = waterS

print(str(water+sugar)+" "+str(sugar))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
maxden = 0
amax = f //(a*100)
water=a
sugar=0
for i in range(amax+1):
  waterA = i*100*a
  res = f-waterA
  bmax = res // (b*100)
  for j in range(bmax+1):
    waterB = j*100*b
    waterS =waterA+waterB
    res = f-waterS
    cmax = res // c
    for k in range(cmax+1):
      sugarC = k*c
      res = f-waterS-sugarC
      dmax = res // d
      for l in range(dmax+1):
        sugarD = l*d
        sugarS = sugarC+sugarD
        if(sugarS+waterS==0):break
        den = (sugarS)*100/(sugarS+waterS)
        #if(den>49 and den<50.1):print(res-sugarD,waterA,waterB,sugarC,sugarD,den)
        if(den>maxden and ((den*(100+e))/100)<=(e)):
          maxden = den
          sugar = sugarS
          water = waterS

print(str(water+sugar)+" "+str(sugar))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
maxden = 0
amax = f //(a*100)
water=0
sugar=0
for i in range(amax+1):
  waterA = i*100*a
  res = f-waterA
  bmax = res // (b*100)
  for j in range(bmax+1):
    waterB = j*100*b
    waterS =waterA+waterB
    res = f-waterS
    cmax = res // c
    for k in range(cmax+1):
      sugarC = k*c
      res = f-waterS-sugarC
      dmax = res // d
      for l in range(dmax+1):
        sugarD = l*d
        sugarS = sugarC+sugarD
        if(sugarS+waterS==0):break
        den = (sugarS)*100/(sugarS+waterS)
        #if(den>49 and den<50.1):print(res-sugarD,waterA,waterB,sugarC,sugarD,den)
        if(den>maxden and ((den*(100+e))/100)<=(e)):
          maxden = den
          sugar = sugarS
          water = waterS

print(str(water+sugar)+" "+str(sugar))

Submission status: Wrong Answer

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

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D

                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar

print(sw_max,s_max)

Submission status: Wrong Answer

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

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D
                
                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if water + sugar <= F and sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar

print(sw_max,s_max)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
def gcd(x, y):
    xx = (abs(x+y)-abs(x-y)) // 2
    yy = (abs(x+y)+abs(x-y)) // 2
    if yy % xx == 0:
        return xx
    else:
        return gcd(yy % xx, xx)

g = gcd(C, D)
Cmax = 0
Hmax = 0
Smax = 0
for p in range(F // (100*A) + 2):
    for q in range((F - 100*p*A) // (100*B) + 2):
        H2O = 100 * p * A + 100 * q * B
        lev = min([F - H2O, E*H2O // 100])
        sugar = 0
        if lev > 0 and H2O != 0:
            if lev < C:
                sugar = 0
            elif lev < C + D - q:
                sugar = max([(lev // C)*C, (lev//D)*D,])
            else:
                sugar = (lev // g) * g
            if Cmax < sugar/(H2O+sugar):
                Cmax = sugar / (H2O+sugar)
                Hmax = H2O
                Smax = sugar

print("{0} {1}".format(Smax+Hmax, Smax))

Submission status: Wrong Answer

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

e = 100 * e / (100 + e)

res_ratio = 0
res_total = 0
res_sugar = 0

# 全探索
for a_water in range(0, f+1, a):
    for b_water in range(0, f - a_water+1, b):
        for c_sugar in range(0, f - a_water - b_water+1, c):
            for d_sugar in range(0, f - a_water - b_water - c_sugar+1, d):
                if (a_water + b_water + c_sugar + d_sugar) == 0:
                    pass
                else:
                    ratio = 100 * (c_sugar + d_sugar) / (a_water + b_water + c_sugar + d_sugar)
                    if res_ratio < ratio <= e and (a_water + b_water + c_sugar + d_sugar) <= f:
                        res_total = (a_water + b_water + c_sugar + d_sugar)
                        res_sugar = c_sugar + d_sugar
                        res_ratio = ratio
                    elif ratio > e:
                        break
print(res_total, res_sugar)