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:
def func(a, b):
    a = float(a)
    b = float(b)
    try:
        return float((100 * b) / (a + b))
    except:
        return 0

A, B, C, D, E, F = map(float, raw_input().split())

w = []
s = []

F = int(F)

for i in range(F):
    for j in range(F - i):
        if i*100*A + j*100*B <= F:
            w.append(i * 100 * A + j * 100 * B)

maxes = [0, 0]

for k in w:
    for i in range(F):
        for j in range(F - i):
            tmp = i*C + j*D
            if int(tmp + k) <= F:
                if func(k, tmp) <= func(100.0, E) and func(k, tmp) > func(maxes[0], maxes[1]):
                    maxes[0], maxes[1] = k, tmp

print int(maxes[0] + maxes[1]), int(maxes[1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc074/tasks/arc083_a
WA
"""
import sys
from sys import stdin
input = stdin.readline


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

    w = []
    s = []
    for i in range(int(F/100)+1):
        for j in range(int(F/100)+1):
            water = 100*A*i + 100*B*j
            if  water <= F and water > 0:
                w.append(water)

    for i in range(F+1):
        for j in range(F+1):
            sugar = C*i + D*j
            if sugar <= F and sugar > 0:
                s.append(sugar)

    max_density = (100*E) / (100 + E)
    record_density = 0.0
    record = [0, w[0]]
    for i in w:
        for j in s:
            if i+j <= F:
                density = (100 * j) / (i + j)
                if density > record_density and density <= max_density:
                    record_density = density
                    record = [i+j, j]

    print(*record)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

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

def ql():
    ans = (0,A)
    for a in range(0,F,A):
        for b in range(0,F,B):
            for c in range(0,F,C):
                for d in range(0,F,D):
                    wat = (a + b)
                    sug = (c + d)
                    if sug == 0 or wat == 0:
                        break
                    e = (100*sug)/wat
                    if wat+sug > F or e > E:
                        break
                    elif e == E:
                        return (sug,wat)
                    elif e < E and e > (100*ans[0])/ans[1]:
                        ans = (sug,wat)  
    return ans
ans = ql()
print(str(ans[0]+ans[1]) + " " + str(ans[0]))

Submission status: Wrong Answer

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

def ql():
    ans = (0,A)
    for a in range(0,F,A):
        for b in range(0,F,B):
            for c in range(0,F,C):
                for d in range(0,F,D):
                    wat = (a + b)
                    sug = (c + d)
                    if sug == 0 or wat == 0:
                        break
                    e = int(100*sug/wat)
                    if wat+sug > F or e > E:
                        break
                    elif e == E:
                        return (sug,wat)
                    elif e < E and e > int(100*ans[0]/ans[1]):
                        ans = (sug,wat)  
    return ans
ans = ql()
print(str(ans[0]+ans[1]) + " " + str(ans[0]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc074/tasks/arc083_a
WA
"""
import sys
from sys import stdin
input = stdin.readline


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

    w = []
    s = []
    for i in range(int(F/100)+1):
        for j in range(int(F/100)+1):
            water = 100*A*i + 100*B*j
            if  water <= F and water > 0:
                w.append(water)

    for i in range(F+1):
        for j in range(F+1):
            sugar = C*i + D*j
            if sugar <= F and sugar > 0:
                s.append(sugar)

    max_density = (100*E) / (100 + E)
    record_density = 0
    record = [0, 0]
    for i in w:
        for j in s:
            if i+j <= F:
                density = (100 * j) / (i + j)
                if density > record_density and density <= max_density:
                    record_density = density
                    record = [i+j, j]

    print(*record)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc074/tasks/arc083_a

"""
import sys
from sys import stdin
input = stdin.readline


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

    w = []
    s = []
    for i in range(int(F/100)+1):
        for j in range(int(F/100)+1):
            water = 100*A*i + 100*B*j
            if  water <= F and water > 0:
                w.append(water)

    for i in range(F+1):
        for j in range(F+1):
            sugar = C*i + D*j
            if sugar <= F and sugar > 0:
                s.append(sugar)

    max_density = (100*E) / (100 + E)
    record_density = 0
    record = []
    for i in w:
        for j in s:
            if i+j <= F:
                density = (100 * j) / (i + j)
                if density > record_density and density <= max_density:
                    record_density = density
                    record = [i+j, j]

    print(*record)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

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

def ql():
    ans = (0,A)
    for a in range(0,F,A):
        for b in range(0,F,B):
            for c in range(0,F,C):
                for d in range(0,F,D):
                    wat = (a + b)
                    sug = (c + d)
                    if sug == 0 or wat == 0:
                        break
                    e = 100*sug/wat
                    if wat+sug > F or e > E:
                        break
                    elif int(e) == E:
                        return (sug,wat)
                    elif e < E and e > 100*ans[0]/ans[1]:
                        ans = (sug,wat)  
    return ans
ans = ql()
print(str(ans[0]+ans[1]) + " " + str(ans[0]))

Submission status: Wrong Answer

Solution code:
x = raw_input()
x = x.split(' ')
x = [int(d) for d in x]
a,b,c,d,e,f = x

sitsuryo = a*100
count_d = 0
while(1):
	sitsuryo += d
	count_d += 1
	if(count_d*d/a > e):
		break
	if(sitsuryo > f):
		break

sitsuryo -= d
count_d -= 1

count_c = 0
while(1):
	sitsuryo += c
	count_c += 1
	if((count_c*c + count_d*d)/a > e):
		break
	if(sitsuryo > f):
		break

sitsuryo -= c
count_c -= 1

satou = count_c*c + count_d*d

print("{} {}".format(sitsuryo,satou))

Submission status: Wrong Answer

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

def ql():
    ans = (0,1)
    for a in range(0,F,A):
        for c in range(0,F,C):
            for b in range(0,F,B):
                for d in range(0,F,D):
                    wat = (a + b)
                    sug = (c + d)
                    if sug+wat == 0 or wat == 0:
                        continue
                    e = sug/wat*100
                    if wat+sug > F or e > E:
                        continue
                    elif int(e) == E:
                        return (sug,wat)
                    elif e < E and e > ans[0]/ans[1]*100:
                        ans = (sug,wat)  
    return ans
ans = ql()
print(str(ans[0]+ans[1]) + " " + str(ans[0]))

Submission status: Wrong Answer

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

def ql():
    ans = (0,1)
    for a in range(0,F,A):
        for c in range(0,F,C):
            for b in range(0,F,B):
                for d in range(0,F,D):
                    wat = (a + b)
                    sug = (c + d)
                    if sug+wat == 0 or wat == 0:
                        break
                    e = sug/wat*100
                    if wat+sug > F or e > E:
                        break
                    elif int(e) == E:
                        return (sug,wat)
                    elif e < E and e > ans[0]/ans[1]*100:
                        ans = (sug,wat)  
    return ans
ans = ql()
print(str(ans[0]+ans[1]) + " " + str(ans[0]))

Submission status: Wrong Answer

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

def ql():
    ans = (0,1)
    for a in range(0,F,A):
        for c in range(0,F,C):
            for b in range(0,F,B):
                for d in range(0,F,D):
                    wat = (a + b)
                    sug = (c + d)
                    if sug+wat == 0 or wat == 0:
                        break
                    e = sug/wat
                    if wat+sug > F or e*100>E:
                        break
                    elif int(e/100) == E:
                        return (sug,wat)
                    elif e/100 < E and e > ans[0]/ans[1]:
                        ans = (sug,wat)  
    return ans
ans = ql()
print(str(ans[0]+ans[1]) + " " + str(ans[0]))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      for k in range(max_salt//C+1):#Cを何個使うか
        l=(max_salt-C*k)//D#Dは何個つかえるか
        salt=k*C+l*D
        if water+salt>F: salt-=D
        rate=100*salt/(water+salt)
        if rate>=best_rate and water+salt<=F:
          best_rate=rate
          best_salt=salt
          best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      for k in range(max_salt//C+1):#Cを何個使うか
        l=(max_salt-C*k)//D#Dは何個つかえるか
        salt=k*C+l*D
        rate=100*salt/(water+salt)
        if rate>=best_rate and water+salt<=F:
          best_rate=rate
          best_salt=salt
          best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

def main():
    A, B, C, D, E, F = [int(x) for x in input().split()]
    max_rate = E / (100 + E)
    best_weight, best_suger, best_rate = 0, 0, 0.0
    for a in range(1, F//100 +1):
        for b in range((F-a*A)//100 + 1):
            water = (a*A+b*B)*100
            if water > F:
                continue
            for c in range((F-water)//C + 1):
                d = min((F - water - c*C) // D, int((E*water-100*c*C) / (100*D)))
                if d < 0:
                    continue
                suger = c*C + d*D
                if water + suger > F:
                    continue
                if water + suger == 0:
                    rate = 0.0
                else:
                    rate = suger / (water + suger)
                if rate > max_rate:
                    continue
                if rate > best_rate:
                    best_weight = water + suger
                    best_suger = suger
                    best_rate = rate
    print(best_weight, best_suger)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      salt=0
      for k in range(max_salt//C+1):#Cを何個使うか
        for l in range(max_salt//D+1):#Dは何個つかえるか
          if k*C+l*D<=max_salt: salt=max(k*C+l*D,salt)
      rate=100*salt/(water+salt)
      if rate>=best_rate and rate<=E and water+salt<=F:
        best_rate=rate
        best_salt=salt
        best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      salt=0
      for k in range(max_salt//C+1):#Cを何個使うか
        for l in range(max_salt//D+1):#Dは何個つかえるか
          if k*C+l*D<=max_salt: salt=max(k*C+l*D,salt)
      rate=100*salt/(water+salt)
      if rate>best_rate and rate<=E and water+salt<=F:
        best_rate=rate
        best_salt=salt
        best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

[a,b,c,d,e,f]=i2()
g=[[0,100*a,0]]
for i in range(31):
    for j in range(31):
                ttt=(a*i+b*j)*100
                tk=min(ttt*e/100,f-ttt)
                tt=(tk//d)*d+(tk%d//(d-c))*(d-c)
                t=ttt+tt
                if t>0 :
                    g.append([(100*tt)/t,t,tt])

g.sort()
print(int(g[-1][1]),int(g[-1][2]))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      for k in range(max_salt//C+1):#Cを何個使うか
        l=(max_salt-C*k)//D#Dは何個つかえるか
        salt=k*C+l*D
        rate=100*salt/(water+salt)
        if rate>=best_rate and salt<=max_salt and rate<=E and water+salt<=F and l>=0:
          best_rate=rate
          best_salt=salt
          best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      for k in range(max_salt//C+1):#Cを何個使うか
        l=(max_salt-C*k)//D#Dは何個つかえるか
        salt=k*C+l*D
        rate=100*salt/(water+salt)
        if rate>best_rate and salt<=max_salt and rate<=E and water+salt<=F and l>=0:
          best_rate=rate
          best_salt=salt
          best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      for k in range(max_salt//C+1):#Cを何個使うか
        l=(max_salt-C*k)//D#Dは何個つかえるか
        salt=k*C+l*D
        rate=100*salt/(water+salt)
        if rate>best_rate and salt<=max_salt and rate<=E and water+salt<=F and l:
          best_rate=rate
          best_salt=salt
          best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      for k in range(max_salt//C+1):#Cを何個使うか
        l=(max_salt-C*k)//D#Dは何個つかえるか
        salt=k*C+l*D
        rate=100*salt/(water+salt)
        if rate>best_rate and salt<=max_salt and rate<=E and water+salt<=F:
          best_rate=rate
          best_salt=salt
          best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

Solution code:
def func(a, b):
    return float((100 * b) / (a + b))

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

e = float(E)
a = float(100 * A)
b = float(100 * B)
c = float(C)
d = float(D)
f = F

max_con = 0.0
maxes = [0, 0]

q = [[a, 0], [b, 0]]


while len(q) != 0:
    tmp = []
    key = q.pop(0)
    if key[0] + key[1] <= f:
        if key[1] / key[0] <= e / 100:
            if max_con <= func(key[0], key[1]):
                max_con = func(key[0], key[1])
                maxes[0], maxes[1] = key[0], key[1]
            tmp += [key[0], key[1] + c]
            tmp += [key[0], key[1] + d]
        else:
            tmp += [key[0] + a, key[1]]
            tmp += [key[0] + b, key[1]]
    
    if len(tmp) > 0:
        q.append(tmp)

print int(maxes[0] + maxes[1]), int(maxes[1])

Submission status: Wrong Answer

Solution code:
def func(a, b):
    return float((100 * b) / (a + b))

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

e = float(E)
a = float(100 * A)
b = float(100 * B)
c = float(C)
d = float(D)
f = F

max_con = 0.0
maxes = [0, 0]

q = [[a, 0], [b, 0]]


while len(q) != 0:
    tmp = []
    key = q.pop(0)
    if key[0] + key[1] <= f:
        print key[1]
        if key[1] / key[0] <= e / 100:
            if max_con <= func(key[0], key[1]):
                max_con = func(key[0], key[1])
                maxes[0], maxes[1] = key[0], key[1]
            tmp += [key[0], key[1] + c]
            tmp += [key[0], key[1] + d]
        else:
            tmp += [key[0] + a, key[1]]
            tmp += [key[0] + b, key[1]]
    
    if len(tmp) > 0:
        q.append(tmp)

print int(maxes[0] + maxes[1]), int(maxes[1])

Submission status: Wrong Answer

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

    water = 100 * A
    sugar = A * E
    s1 = 0
    i = 0
    while True:
        c = i * C
        d = (sugar - c) // D * D
        s1 = max(s1, c + d)
        if c >= sugar:
            break
        i += 1

    water = 100 * B
    sugar = B * E
    s2 = 0
    i = 0
    while True:
        c = i * C
        d = (sugar - c) // D * D
        s2 = max(22, c + d)
        if c >= sugar:
            break
        i += 1

    x1 = (100 * s1) / (A * 100 + s1)
    x2 = (100 * s2) / (A * 100 + s2)
    if A * 100 + s1 > F:
        x1 = 0
    if B * 100 + s2 > F:
        x2 = 0
    if x1 >= x2:
        print(A * 100 + s1, s1)
    else:
        print(B * 100 + s2, s2)

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

import sys

def solution(A, B, C, D, E, F):
    max_percentage = 0
    mass = 0
    mass_sugar = 0

    for c in xrange(0, int(F/C) + 1):
        if (c * C) > F:
            break

        for d in xrange(0, int(F/D) + 1):
            sugar = c * C + d * D
            if sugar > F:
                break

            for a in xrange(0, int(F/A) + 1):
                if (sugar + 100 * a * A) > F:
                    break

                for b in xrange(0, int(F/B) + 1):
                    water = 100 * a * A + 100 * b * B
                    if (sugar + water) > F:
                        break

                    if sugar <= (int(water / 100) * E):
                        if water > 0:
                            percentage = float(sugar) / water * 100
                        else:
                            percentage = 0

                        if percentage > max_percentage:
                            mass = sugar + water
                            mass_sugar = sugar
                            max_percentage = percentage

                        if max_percentage == 100:
                            return mass, mass_sugar

    return mass, mass_sugar

def main(argv):
    line = sys.stdin.readline()

    while line:
        A, B, C, D, E, F = map(int, line.rstrip("\n").split(" ", 6))

        mass, mass_sugar = solution(A, B, C, D, E, F)
        print("{0} {1}".format(mass, mass_sugar))

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Submission status: Wrong Answer

Solution code:
def solve():
    
    A, B, C, D, E, F = map(int, input().split())
    memo = {}
    
    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    if a == 0 and b == 0:
                        break
                    if (100*A)*a + (100*B)*b + C*c + D*d > F:
                        break
                    if C*c + D*d > E:
                        break
                    density = 100 * (C*c+D*d) / ( (100*A)*a + (100*B)*b + C*c + D*d )
                    memo[a,b,c,d]= density
    
    max_v = max(memo.values())
    
    for k, v in memo.items():
        if v == max_v:
            print((100*A)*k[0] + (100*B)*k[1] + min(C*k[2] + D*k[3], E), min(C*k[2] + D*k[3], E) )
            break

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      for k in range(max_salt//C+1):#Cを何個使うか
        for l in range(max_salt//D+1):#Dは何個つかえるか
          salt=k*C+l*D
          rate=100*salt/(water+salt)
          if rate>best_rate and salt<= max_salt and rate<=E and water+salt<=F:
            best_rate=rate
            best_salt=salt
            best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = [int(v) for v in input().split()]
# print(A, B, C, D, E, F)
An = [(100*A)*(v) for v in range(int(F/(100*A))+1)]
Bn = [(100*B)*(v) for v in range(int(F/(100*B))+1)]
# print(An, Bn, 1)
 
 
def per1(RE):
  Cn = [C*v for v in range(int(RE/C)+1)]
  Dn = [D*v for v in range(int(RE/D)+1)]
  rtn = 0
  for v2 in Cn:
    for w2 in Dn:
      r = v2 + w2
      if rtn < r <= RE:
        rtn = r
  return rtn
  
  
max_suger_per = 0
max_water = 0
max_suger = 0
for v in Bn:
  for w in An:
    s = v + w
    if s > F or s == 0: continue
    re = int(s * E / 100)
    if s + re > F: re = F - s
    # print(s, re)
    result = per1(re)
    # print(result)
    suger = (100 * result) / (s + result)
    if suger > max_suger_per:
      max_suger_per = suger
      max_water = s + result
      max_suger = result
    
print(max_water, max_suger)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = [int(v) for v in input().split()]
# print(A, B, C, D, E, F)
An = [(100*A)*(v) for v in range(int(F/(100*A))+1)]
Bn = [(100*B)*(v) for v in range(int(F/(100*B))+1)]
# print(An, Bn, 1)


def per1(RE):
  Cn = [A*v for v in range(int(RE/A)+1)]
  Dn = [B*v for v in range(int(RE/B)+1)]
  # print(int(RE/C))
  rtn = 0
  for v2 in Cn:
    for w2 in Dn:
      r = v2 + w2
      if rtn < r <= RE:
        rtn = r
  return rtn
  
  
max_suger_per = 0
max_water = 0
max_suger = 0
for v in Bn:
  for w in An:
    s = v + w
    if s > F or s == 0: continue
    re = int(s * E / 100)
    if s + re > F: re = F - s
    # print(s, re)
    result = per1(re)
    # print(result)
    suger = (100 * result) / (s + result)
    if suger > max_suger_per:
      max_suger_per = suger
      max_water = s + result
      max_suger = result
    
print(max_water, max_suger)

Submission status: Wrong Answer

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

max = 0
water = 0
sugar = 0
flag = True

i = 1
while(f >= 100 * a * i):
    j = 0
    while(f >= 100 * (a * i + b * j)):
        k = 0
        while(f >= 100 * (a * i + b * j) + c * k):
            l = 0
            while(f >= 100 * (a * i + b * j) + c * k + d * l):
                n = 100 * (c * k + d * l) / (100 * (a * i + b * j) + c * k + d * l)
                if(n > 100 * e / (100 + e)):
                    break
                if(max < n):
                    max = n
                    water = 100 * (a * i + b * j)
                    sugar = c * k + d * l
                l += 1
            k += 1
        j += 1
    i += 1

i = 0
j = 1
while(f >= 100 * (a * i + b * j)):
    k = 0
    while(f >= 100 * (a * i + b * j) + c * k):
        l = 0
        while(f >= 100 * (a * i + b * j) + c * k + d * l):
            n = 100 * (c * k + d * l) / (100 * (a * i + b * j) + c * k + d * l)
            if(n > 100 * e / (100 + e)):
                break
            if(max < n):
                max = n
                water = 100 * (a * i + b * j)
                sugar = c * k + d * l
            l += 1
        k += 1
    j += 1

print("%d %d" %(water + sugar, sugar))

Submission status: Wrong Answer

Solution code:
def check(a, b, c, d, sugarwater, sugar):
  water = sugarwater - sugar
  judge = [ 0 for i in range(2) ]

  judge[0] = True if water % (a * 100) == 0 or water % (b * 100) == 0 else False
  judge[1] = True if sugar % c == 0 or sugar % d == 0 else False

  if(judge[0] and judge[1]):
    return True
  else:
    return False

def main():
  i = input().split()
  a, b, c, d, e, f = [ int(x) for x in i ]
  sugarwater = 100 + e
  sugar = e
  count = True

  while check(a, b, c, d, sugarwater, sugar) is False:
    print('%d %d' % (sugarwater, sugar))
    if sugarwater == 0 or sugar == 0: count = False

    if count:
      sugarwater -= 1
      sugar -= 1
    else:
      sugarwater += 1
      sugar += 1
      
  print('%d %d' % (sugarwater, sugar))  

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

max = 0
water = 0
sugar = 0
flag = True

i = 1
while(f >= 100 * a * i):
    j = 0
    while(f >= 100 * (a * i + b * j)):
        k = 0
        while(f >= 100 * (a * i + b * j) + c * k):
            l = 0
            while(f >= 100 * (a * i + b * j) + c * k + d * l):
                n = 100 * (c * k + d * l) / (100 * (a * i + b * j) + c * k + d * l)
                if(n > 100 * e / (100 + e)):
                    break
                if(max < n):
                    max = n
                    water = 100 * (a * i + b * j)
                    sugar = c * k + d * l
                l += 1
            k += 1
        j += 1
    i += 1

j = 1
while(f >= 100 * (a * i + b * j)):
    k = 0
    while(f >= 100 * (a * i + b * j) + c * k):
        l = 0
        while(f >= 100 * (a * i + b * j) + c * k + d * l):
            n = 100 * (c * k + d * l) / (100 * (a * i + b * j) + c * k + d * l)
            if(n > 100 * e / (100 + e)):
                break
            if(max < n):
                max = n
                water = 100 * (a * i + b * j)
                sugar = c * k + d * l
            l += 1
        k += 1
    j += 1

print("%d %d" %(water + sugar, sugar))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      for k in range(max_salt//C+1):#Cを何個使うか
        l=(max_salt-C*k)//D#Dは何個つかえるか
        salt=k*C+l*D
        rate=100*salt/(water+salt)
        if rate>best_rate and rate<=E and water+salt<=F:
          best_rate=rate
          best_salt=salt
          best_water=water
print(best_water+best_salt,best_salt)

Submission status: Wrong Answer

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

w_m=0
s_m=0

a_max=F/(100*A)
b_max=F/(100*B)

def sugar(w):
    c_max=(F-w)/C
    d_max=(F-w)/D
    m=0
    for c in range(0,c_max+1):
        for d in range(0,d_max+1):
            if (C*c+D*d)>E*w/100. or (C*c+D*d)+w>F:
                continue
            elif (C*c+D*d)>m:
                m=(C*c+D*d)
    return m

m=0.
for a in range(0,a_max+1):
    for b in range(0,b_max+1):
        w=100*(A*a+B*b)
        if w>F:
            continue
        s=sugar(w)
        if (w+s)==0 or w+s>F:
            continue
        elif 100.*s/(w+s)>m:
            m=100.*s/(w+s)
            w_m=w
            s_m=s

print int(w_m+s_m),s_m

Submission status: Wrong Answer

Solution code:
import fractions
a = list(map(int,input().split()))

g = 100 + a[4]
h = a[5] // g

water = [0] * (h + 1)
suger = [0] * (a[4] * h + 1)
water[0] = 1
suger[0] = 1

for j in range(100):
    for i in range(h, -1, -1):
        if i - a[0] >= 0:
            water[i] = max(water[i], water[i - a[0]])
        if i - a[1] >= 0:
            water[i] = max(water[i], water[i - a[1]])

for j in range(100):
    for i in range(a[4] * h, -1, -1):
        if i - a[2] >= 0:
            suger[i] = max(suger[i], suger[i - a[2]])
        if i - a[3] >= 0:
            suger[i] = max(suger[i], suger[i - a[3]])

ans = [0] * 3
for i in range(1, h + 1):
    if water[i] == 0:
        continue
    for j in range(a[4]):
        if suger[i * a[4] - j] == 1:
            if fractions.Fraction(i * a[4] - j ,i * 100) > ans[2]:
                ans = [i * 100 + i * a[4] - j, i * a[4] - j, \
                    fractions.Fraction(i * a[4] - j ,i * 100)]

if ans[0] == 0:
    if a[0] < a[1]:
        print(a[0] * 100, 0)
    else:
        print(a[1] * 100, 0)
else:
    print(ans[0], ans[1])