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):
#
# abc074 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 2 10 20 15 200"""
        output = """110 10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 1 2 100 1000"""
        output = """200 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """17 19 22 26 55 2802"""
        output = """2634 934"""
        self.assertIO(input, output)


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    w = 0
    s = 0
    while w + B <= F//100:
        w += B
        while w + A <= F//100:
            w += A
            while 100*w + s <= F and s + D <= E*w:
                s += D
                while 100*w + s <= F and s + C <= E*w:
                    s += C
    print(f"{100*w+s} {s}")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Fixed, accepted submission:
#
# abc074 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 2 10 20 15 200"""
        output = """110 10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 1 2 100 1000"""
        output = """200 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """17 19 22 26 55 2802"""
        output = """2634 934"""
        self.assertIO(input, output)


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    N = 0
    W = 100*A
    S = 0
    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    w = A*i+B*j
                    s = C*k+D*l
                    if w == 0 or 100*w+s > F or s > w*E:
                        break
                    n = 100*s / (100*w+s)
                    if n > N:
                        N = n
                        W = 100*w+s
                        S = s
    print(f"{W} {S}")


if __name__ == "__main__":
    # unittest.main()
    resolve()