Problem:
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.

Incorrect submission (verdict: Wrong Answer):
# -*- coding:utf-8 -*-

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

    
    
    dp= [0]*(F+1)

    for i in range(1, F+1):
        if i+100*A <= F:
            concent = (dp[i]*i)/(i+100*A)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*A] = max(dp[i+100*A], concent)
        if i+100*B <= F:
            concent = (dp[i]*i)/(i+100*B)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*B] = max(dp[i+100*B], concent)
        if i+C <= F:
            concent = (dp[i]*i+C)/(i+C)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+C] = max(dp[i+C], concent)
        if i+D <= F:
            concent = (dp[i]*i+D)/(i+D)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+D] = max(dp[i+D], concent)
    
    max_concent = max(dp)
    print(dp.index(max_concent), round(dp.index(max_concent)*max_concent))



if __name__ == "__main__":
    solve()


Fixed, accepted submission:
# -*- coding:utf-8 -*-



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

    
    sugars = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            y = i*C + j*D
            if y <= F:
                
                sugars.append(y)

    water = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            x = 100*A*i + 100*B*j
            if x <= F:
                
                water.append(x)
    
    sugars.sort()
    water.sort()

    
    concent = 0
    for x in water:
        for y in sugars:
            if x+y > F:
                break
            if x+y > 0 and y/(x+y) <= E/(100+E):
                if y/(x+y) >= concent:
                    concent = y/(x+y)
                    ans = "{} {}".format(x+y, y)
    print(ans)


def solve():
    """ WA """
    A, B, C, D, E, F = list(map(int, input().split()))

    
    
    dp= [0]*(F+1)

    for i in range(0, F+1):
        if i+100*A <= F:
            concent = (dp[i]*i)/(i+100*A)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*A] = max(dp[i+100*A], concent)
        if i+100*B <= F:
            concent = (dp[i]*i)/(i+100*B)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*B] = max(dp[i+100*B], concent)
        if i+C <= F:
            concent = (dp[i]*i+C)/(i+C)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+C] = max(dp[i+C], concent)
        if i+D <= F:
            concent = (dp[i]*i+D)/(i+D)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+D] = max(dp[i+D], concent)
    
    print(dp)
    return
    max_concent = max(dp)
    print(dp.index(max_concent), round(dp.index(max_concent)*max_concent))



if __name__ == "__main__":
    solve2()