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:
import math
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

def AddV2(v,w):
    return [v[0]+w[0],v[1]+w[1]]

dir4 = [[1,0],[0,1],[-1,0],[0,-1]]


def clamp(x,y,z):
    return max(y,min(z,x))

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
#
def Zaatsu(a):
    a.sort()
    now = a[0][0]
    od = 0
    for i in range(n):
        if(now==a[i][0]):
            a[i][0]=od
        else:
            now = a[i][0]
            od+=1
            a[i][0] = od
    
    a.sort(key = lambda x : x[1])
    return a

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

def rl(x):
    return range(len(x))

# a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



#21-


a,b,c,d,e,f= list(map(int, input().split()))
ans = [100,-1]
maxim = -0.1

for i in range(30):
    for j in range(30):
        for k in range(1500):
            water = 100*(a*i+b*j)
            if(water==0):
                continue
            sugar = c*k
            maxSugar = e*water//100
            l = (maxSugar - sugar)//d
            sugar = c*k + d*l
            ratio = [sugar,(sugar+water)]
            if(ratio[1]*ans[1]<ratio[0]*ans[0] and sugar+water<=f):
                maxim = ratio
                ans = [water+sugar,sugar]

print(*ans)

Submission status: Wrong Answer

Solution code:
import math
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

def AddV2(v,w):
    return [v[0]+w[0],v[1]+w[1]]

dir4 = [[1,0],[0,1],[-1,0],[0,-1]]


def clamp(x,y,z):
    return max(y,min(z,x))

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
#
def Zaatsu(a):
    a.sort()
    now = a[0][0]
    od = 0
    for i in range(n):
        if(now==a[i][0]):
            a[i][0]=od
        else:
            now = a[i][0]
            od+=1
            a[i][0] = od
    
    a.sort(key = lambda x : x[1])
    return a

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

def rl(x):
    return range(len(x))

# a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



#21-


a,b,c,d,e,f= list(map(int, input().split()))
ans = [0,0]
maxim = -0.1

for i in range(30):
    for j in range(30):
        for k in range(1500):
            water = 100*(a*i+b*j)
            if(water==0):
                continue
            sugar = c*k
            maxSugar = e*water//100
            l = (maxSugar - sugar)//d
            sugar = c*k + d*l
            ratio = sugar/(sugar+water)
            if(maxim<ratio and sugar+water<=f):
                maxim = ratio
                ans = [water+sugar,sugar]

print(*ans)

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D, E, F = list(map(int, input().split()))
    A *= 100
    B *= 100
    dp = [[0] * 3000 for _ in range(3000)]
    dp[0][0] = 1
    m = 0
    mt = (0, 0)
    for i in range(3000):
        for j in range(3000):
            if dp[i][j] == 0:
                continue
            if i + A <= F:
                dp[i+A][j] = 1
            if i + B <= F:
                dp[i+B][j] = 1
            if i + C <= F:
                dp[i+C][j+C] = 1
                if (j+C)/(i+C) > m and (j+C)/(i+C)<= E/(100+E):
                    m = (j+C)/(i+C)
                    mt = ((i+C), (j+C))
            if i + D <= F:
                dp[i+D][j+D] = 1
                if (j+D)/(i+D) > m and (j+D)/(i+D)<= E/(100+E):
                    m = (j+D)/(i+D)
                    mt = ((i+D), (j+D))
    return mt
mt = main()
print(mt[0], mt[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
maxm = 100*a
maxs = 0
water = set()
suger = set()
for i in range(31):
    for j in range(31):
        if i*a*100 + j*b*100 <= f and i*a*100 + j*b*100 > 0:
            water.add(i*a*100+j*b*100)
        suger.add(c*i+d*j)
for i in water:
    for j in suger:
        if i*e//100 >= j and i+j <= f:
            tmpm = i + j
            tmps = j
            if tmps*maxm > maxs*tmpm:
                maxm = tmpm
                maxs = tmps
print(maxm,maxs)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
def y(ai,bi,n):
    flag = False
    count = ai
    while count <= n:
        if (n - count) % bi == 0:
            flag = True
        count += ai
    return flag
maxm = 100*a
maxs = 0
for i in range(100,f+1):
    if i % 100 == 0:
        if y(a*100,b*100,i):
            for j in range(i//100*e+1):
                if y(c,d,j):
                    tmpm = i+j
                    tmps = j
                    if tmpm <= f and tmps*maxm > maxs*tmpm:
                        maxm = tmpm
                        maxs = tmps
print(maxm,maxs)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
def y(ai,bi,n):
    flag = False
    count = ai
    while count <= n:
        if (n - count) % bi == 0:
            flag = True
        count += ai
    return flag
maxm = 100*a
maxs = 0
for i in range(100,f+1):
    if i % 100 == 0:
        if y(a*100,b*100,i):
            for j in range(i//100*e+1):
                if y(c,d,j):
                    tmpm = i+j
                    tmps = j
                    if tmpm <= f and tmps/tmpm > maxs/maxm:
                        maxm = tmpm
                        maxs = tmps
print(maxm,maxs)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
def y(ai,bi,n):
    flag = False
    count = ai
    while count <= n:
        if (n - count) % bi == 0:
            flag = True
        count += ai
    return flag
maxm = -1
maxs = 1
for i in range(100,f+1):
    if i % 100 == 0:
        if y(a*100,b*100,i):
            for j in range(i//100*e+1):
                if y(c,d,j):
                    tmpm = i+j
                    tmps = j
                    if tmpm <= f and tmps/tmpm > maxs/maxm:
                        maxm = tmpm
                        maxs = tmps
            if maxm == (-1) and maxs == 1:
                maxm = i
                maxs = 0
print(maxm,maxs)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
def y(ai,bi,n):
    flag = False
    count = ai
    while count <= n:
        if (n - count) % bi == 0:
            flag = True
        count += ai
    return flag
maxm = -1
maxs = 1
for i in range(100,f+1):
    if i % 100 == 0:
        if y(a*100,b*100,i):
            for j in range(i//100*e+1):
                if y(c,d,j):
                    tmpm = i+j
                    tmps = j
                    if tmpm <= f and tmps/tmpm > maxs/maxm:
                        maxm = tmpm
                        maxs = tmps
print(maxm,maxs)

Submission status: Wrong Answer

Solution code:
import itertools

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

A = list(range(0,101))
B = list(range(0,101))
ptr = list(itertools.product(A, repeat=2))
ptr2 = list(itertools.product(B, repeat=2))

tmp = 0
ans = [0,0]

for a1,b1 in ptr:
    for c1,d1 in ptr2:
        if (a*a1+b*b1) * e >= c * c1 + d * d1 and (a*a1+b*b1) * 100 + c * c1 + d * d1 <= f:
            if tmp*(a*a1+b*b1) < (c * c1 + d * d1):
                tmp = (c * c1 + d * d1)/(a*a1+b*b1)
                ans = [(a*a1+b*b1) * 100 + c * c1 + d * d1, c * c1 + d * d1]

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

Submission status: Wrong Answer

Solution code:
import itertools

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

A = list(range(0,31))
B = list(range(0,101))
ptr = list(itertools.product(A, repeat=2))
ptr2 = list(itertools.product(B, repeat=2))

tmp = 0
ans = [0,0]

for a1,b1 in ptr:
    for c1,d1 in ptr2:
        if (a*a1+b*b1) * e >= c * c1 + d * d1 and (a*a1+b*b1) * 100 + c * c1 + d * d1 <= f:
            if tmp*(a*a1+b*b1) < (c * c1 + d * d1):
                tmp = (c * c1 + d * d1)/(a*a1+b*b1)
                ans = [(a*a1+b*b1) * 100 + c * c1 + d * d1, c * c1 + d * d1]

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

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=0
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if (a*i+b*j)*100+c*k+d*l<=f:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l
      l=((a*i+b*j)*e-c*k)//d
      if l>0:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if (a*i+b*j)*100+c*k+d*l<=f:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
      l=(f-(a*i+b*j)*100-c*k)//d
      if l>0:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if c*k+d*l<=(a*i+b*j)*e:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
      k=k+1
    j=j+1
  i=i+1
if 100*a+c>f:
  print(100*a,0)
else:
  print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=0
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if (a*i+b*j)*100+c*k+d*l<=f:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l
      l=((a*i+b*j)*e-c*k)//d
      if l>0:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if (a*i+b*j)*100+c*k+d*l<=f:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
      l=(f-(a*i+b*j)*100-c*k)//d
      if l>0:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if c*k+d*l<=(a*i+b*j)*e:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
      k=k+1
    j=j+1
  i=i+1
if 100*a==f:
  print(100*a,0)
else:
  print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=((a*i+b*j)*e-c*k)//d
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if (a*i+b*j)*100+c*k+d*l<=f:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l
      l=(f-(a*i+b*j)*100-c*k)//d
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if c*k+d*l<=(a*i+b*j)*e:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l      
      k=k+1
    j=j+1
  i=i+1
if 100*a==f:
  print(100*a,0)
else:
  print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=((a*i+b*j)*e-c*k)//d
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if (a*i+b*j)*100+c*k+d*l<=f:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l
      l=(f-(a*i+b*j)*100-c*k)//d
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l      
      k=k+1
    j=j+1
  i=i+1
if 100*a==f:
  print(100*a,0)
else:
  print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=int(((a*i+b*j)*e-c*k)//d)
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if (a*i+b*j)*100+c*k+d*l<=f:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l
      k=k+1
    j=j+1
  i=i+1
if 100*a==f:
  print(100*a,0)
else:
  print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=((a*i+b*j)*e-c*k)//d
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if (a*i+b*j)*100+c*k+d*l<=f:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l
      k=k+1
    j=j+1
  i=i+1
if 100*a==f:
  print(100*a,0)
else:
  print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=0
      while c*k+d*l<=(a*i+b*j)*e:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if (a*i+b*j)*100+c*k+d*l<=f:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
        l=l+1
      k=k+1
    j=j+1
  i=i+1
if 100*a==f:
  print(100*a,0)
else:
  print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=0
      while c*k+d*l<=(a*i+b*j)*e:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if (a*i+b*j)*100+c*k+d*l<=f:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
        l=l+1
      k=k+1
    j=j+1
  i=i+1
print(answ+anss,anss)

Submission status: Wrong Answer

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

max_ratio = 0.0
suger_water = 0
suger = 0
for i in range(40):
    for j in range(40):
        for k in range(40):
            for l in range(40):
                if a * i * 100 + b * j * 100 + k * c + l * d <= f and k * c + l * d <= e:
                    if (i == 0 and j == 0):
                        continue
                    if max_ratio < (k * c + l * d) / (a * i * 100 + b * j * 100 + k * c + l * d):
                        max_ratio = (k * c + l * d) / \
                            (a * i * 100 + b * j * 100 + k * c + l * d)
                        suger_water = a * i * 100 + b * j * 100 + k * c + l * d
                        suger = k * c + l * d
print("{} {}".format(suger_water, suger))

Submission status: Wrong Answer

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

max_ratio = 0.0
suger_water = 0
suger = 0
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                if a * 100 + b * 100 + c + d <= f and c + d <= e:
                    if max_ratio < (c+d) / (a * 100 + b * 100 + c + d):
                        max_ratio = (c+d) / (a * 100 + b * 100 + c + d)
                        suger_water = a * 100 + b * 100 + c + d
                        suger = c + d
print("{} {}".format(suger_water, suger))

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
dp = [[False]*(F+1) for i in range(F+1)]
dp[0][0] = True
for f in range(F+1):
  for s in range(F+1):
    if dp[f][s]:
      if f+C<=F and s+C<=F:
        dp[f+C][s+C] = True
      if f+D<=F and s+D<=F:
        dp[f+D][s+D] = True
      if f + A <= F:
        dp[f+A][s] = True
      if f + B <= F:
        dp[f+B][s] = True

ans = (float('inf'), 0)
for f in range(F+1):
  for s in range(F+1):
    if dp[f][s]:
      if s*100 <= E*(f-s):
        if ans[1]*f < ans[0]*s:
          ans = (f, s)

print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

# A + Bの組み合わせはせいぜい1～30のうち作れる数字のみなので全探索

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

if E == 0:
  print(min(A,B) * 100, 0)
  exit(0)

ans = [0,0]
maxrate = 0.0
for a in range(0,F,100 * A):
  for b in range(0,F,100 * B):
    if a == 0 and b == 0:
      continue
    if a + b > F:
      break
    water = a + b
    # waterに対して溶ける最大量は (a + b) * E
    limit = min(int(((a + b) / 100) * E), F - water)
    maxsugar = 0
    for c in range(0,limit + 1,C):
      for d in range(0,limit + 1,D):
        if c + d > limit:
          break
        if c + d > maxsugar:
          maxsugar = c + d
          rate = maxsugar / (water + maxsugar)
          if rate > maxrate:
            maxrate = rate
            ans = [water + maxsugar, maxsugar]
          
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

# A + Bの組み合わせはせいぜい1～30のうち作れる数字のみなので全探索

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

if E == 0:
  print(min(A,B) * 100, 0)
  exit(0)

ans = [0,0]
maxrate = 0.0
for a in range(0,F,100 * A):
  for b in range(0,F,100 * B):
    if a == 0 and b == 0:
      continue
    if a + b > F:
      break
    water = a + b
    # waterに対して溶ける最大量は (a + b) * E
    limit = min(((a + b) // 100) * E, F - water)
    maxsugar = 0
    for c in range(0,limit + 1,C):
      for d in range(0,limit + 1,D):
        if c + d > limit:
          break
        if c + d > maxsugar:
          maxsugar = c + d
          rate = maxsugar / (water + maxsugar)
          if rate > maxrate:
            maxrate = rate
            ans = [water + maxsugar, maxsugar]
          
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

# A + Bの組み合わせはせいぜい1～30のうち作れる数字のみなので全探索

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

ans = [0,0]
maxrate = 0.0
for a in range(0,(F + 100) // 100,A):
  for b in range(0,(F + 100) // 100,B):
    if a == 0 and b == 0:
      continue
    if (a + b) * 100 > F:
      break
    water = (a + b) * 100
    # waterに対して溶ける最大量は (a + b) * E
    limit = min((a + b) * E, F - water)
    maxsugar = 0
    for c in range(0,limit + 1,C):
      for d in range(0,limit + 1,D):
        if c + d > limit:
          break
        if c + d > maxsugar:
          maxsugar = c + d
          rate = maxsugar / (water + maxsugar)
          if rate > maxrate:
            maxrate = rate
            ans = [water + maxsugar, maxsugar]
          
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

# A + Bの組み合わせはせいぜい1～30のうち作れる数字のみなので全探索

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

ans = [0,0]
maxrate = 0.0
for a in range(0,F + 1,A):
  for b in range(0,F + 1,B):
    if a == 0 and b == 0:
      continue
    if (a + b) * 100 > F:
      break
    water = (a + b) * 100
    # waterに対して溶ける最大量は (a + b) * E
    limit = min((a + b) * E, F - water)
    maxsugar = 0
    for c in range(0,limit + 1,C):
      for d in range(0,limit + 1,D):
        if c + d > limit:
          break
        if c + d > maxsugar:
          maxsugar = c + d
          rate = maxsugar / (water + maxsugar)
          if rate > maxrate:
            maxrate = rate
            ans = [water + maxsugar, maxsugar]
          
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

# A + Bの組み合わせはせいぜい1～30のうち作れる数字のみなので全探索

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

ans = [0,0]
maxrate = 0.0
for a in range(0,F,A):
  for b in range(0,F,B):
    if a == 0 and b == 0:
      continue
    if (a + b) * 100 > F:
      break
    water = (a + b) * 100
    # waterに対して溶ける最大量は (a + b) * E
    limit = min((a + b) * E, F - water)
    maxsugar = 0
    for c in range(0,limit,C):
      for d in range(0,limit,D):
        if c + d > limit:
          break
        if c + d > maxsugar:
          maxsugar = c + d
          rate = maxsugar / ((a + b) * 100 + maxsugar)
          if rate > maxrate:
            maxrate = rate
            ans = [water + maxsugar, maxsugar]
          
print(*ans)

Submission status: Wrong Answer

Solution code:
__DEUBG__ = 0

import math
import sys

def pat_water(a, b, limit):
    for i in range(limit//a + 1):
        if a * i > limit:
            continue
        for j in range(limit//b + 1):
            if b * j > limit:
                continue
            if i ==  j == 0:
                continue
            if a*i + b*j <= limit:
                yield a*i + b*j

def pat_sugar(c, d, limit):
    for i in range(limit//c + 1):
        if c * i > limit:
            continue
        for j in range(limit//d + 1):
            if c*i + d*j <= limit:
                yield c*i + d*j

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

if __DEUBG__:
    print(tuple(pat_water(a * 100, b * 100, f)))
    print(tuple(pat_sugar(c, d, f)))

waters = set(pat_water(a * 100, b * 100, f))
waters = sorted(waters)

density = 0, 0, 0
for water in waters:
    water_limit = min(water * e // 100 , f - water)
    sugars = set(pat_sugar(c, d, water_limit))
    for sugar in sorted(sugars):
        if water + sugar > f:
            continue

        tmp_density = (sugar / (water + sugar))
        if tmp_density == (e/(100 + e)):
            print('%d %d'%(sugar + water, sugar))
            sys.exit(0)
        if tmp_density < (e/(100 + e)):
            if tmp_density > density[0]:
                density = tmp_density, sugar + water, sugar

print('%d %d'%(density[1], density[2]))

Submission status: Wrong Answer

Solution code:
__DEUBG__ = 0

import math
import sys

def pat_water(a, b, limit):
    for i in range(limit//a + 1):
        if a * i > limit:
            continue
        for j in range(limit//b + 1):
            if b * j > limit:
                continue
            if i ==  j == 0:
                continue
            if a*i + b*j <= limit:
                yield a*i + b*j

def pat_sugar(c, d, limit):
    for i in range(limit//c + 1):
        if c * i > limit:
            continue
        for j in range(limit//d + 1):
            if c*i + d*j <= limit:
                yield c*i + d*j

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

#if e == 0:
#    print(min(a * 100, b * 100), 0)
#    sys.exit(0)

if __DEUBG__:
    print(tuple(pat_water(a * 100, b * 100, f)))
    print(tuple(pat_sugar(c, d, f)))

waters = set(pat_water(a * 100, b * 100, f))
waters = sorted(waters)

density = 0, 0, 0
#for water in pat_water(a * 100, b * 100, f):
for water in waters:
    water_limit = min(water * e // 100 , f - water)
    sugars = set(pat_sugar(c, d, water_limit))
    for sugar in sorted(sugars):
        if water + sugar > f:
            continue

        tmp_density = (sugar / (water + sugar))
        if tmp_density == (e/100):
            print('%d %d'%(sugar + water, sugar))
            sys.exit(0)
        if tmp_density < (e/100):
            if tmp_density > density[0]:
                density = tmp_density, sugar + water, sugar

print('%d %d'%(density[1], density[2]))

Submission status: Wrong Answer

Solution code:
__DEUBG__ = 0

import math
import sys

def pat_water(a, b, limit):
    for i in range(int(limit/a) + 1):
        if a * i > limit:
            continue
        for j in range(int(limit/b) + 1):
            if b * j > limit:
                continue
            if i ==  j == 0:
                continue
            if a*i + b*j <= limit:
                yield a*i + b*j

def pat_sugar(c, d, limit):
    for i in range(int(limit/c) + 1):
        if c * i > limit:
            continue
        for j in range(int(limit/d) + 1):
            if c*i + d*j <= limit:
                yield c*i + d*j

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

if e == 0:
    print(min(a * 100, b * 100), 0)
    sys.exit(0)

if __DEUBG__:
    print(tuple(pat_water(a * 100, b * 100, f)))
    print(tuple(pat_sugar(c, d, f)))

density = 0, 0, 0
for water in pat_water(a * 100, b * 100, f):
    water_limit = min(water * e / 100 , f - water)
    for sugar in pat_sugar(c, d, water_limit):
        if water + sugar > f:
            continue

        tmp_density = (sugar / (water + sugar))
        if tmp_density == (e/100):
            print('%d %d'%(sugar + water, sugar))
            sys.exit(0)
        if tmp_density < (e/100):
            if tmp_density > density[0]:
                density = tmp_density, sugar + water, sugar

print('%d %d'%(density[1], density[2]))