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: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
res = (100 * a, 0)
for aa in range(0, f + 1, 100 * a):
    for bb in range(0, f + 1, 100 * b):
        w = aa + bb
        if w == 0 or w >= f:
            continue
        r = f - w
        for cc in range(0, r + 1, c):
            for dd in range(0, r + 1, d):
                s = cc + dd
                t = w + s
                if t > f or 100 * s > e * w:
                    continue
                if s * res[0] > res[1] * t:
                    res = (t, s)
print(*res)

Submission status: Accepted

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


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

def bluteforce(limit):
    suger = 0
    for c in range(limit // C + 1):
        for d in range(limit // D + 1):
            tmpsum = c * C + d * D
            if tmpsum > limit:
                break
            suger = max(suger,tmpsum)
    return suger

def greedy(limit):
    suger = 0

    while True:
        if limit >= D:
            limit -= D
            suger += D
            continue
        elif limit >= C:
            limit -= C
            suger += C
            continue
        else:
            return suger

a_m = 0
a_s = 0
dense = 0
for a in range(1, 31):
    for b in range(0, 31):
        water = (100 * a * A) + (100 * b * B)
        if water >= F:
            break
        wei_lim = F - water
        # suger = greedy(min((a * A + b * B) * E, wei_lim))
        suger = bluteforce(min((a * A + b * B) * E, wei_lim))
        mass = water + suger
        d = (suger / mass) * 100
        if d >= dense:
            # print(suger, water, a, b, d)
            dense = d
            a_m = mass
            a_s = suger

print(a_m, a_s)

Submission status: Accepted

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

val_max = 0
for a in range(0,1+F//(100*A)):
  for b in range(0,1+(F - 100*A*a)//(100*B)):
    if (a==0)&(b==0):
      continue
    for c in range(0,1+(F - 100*A*a - 100*B*b)//C):
      for d in range(0,1+(F - 100*A*a - 100*B*b - C*c)//D):
        if C*c+D*d <= E*(A*a+B*b):
          val = (C*c + D*d)/(100*A*a + 100*B*b + C*c + D*d)
          if val >= val_max:
            val_max = val
            ans1 = 100*A*a + 100*B*b + C*c + D*d
            ans2 = C*c + D*d
print(int(ans1),int(ans2))

Submission status: Accepted

Solution code:
aw,bw,cs,ds,ep,fm=map(int,input().split())

na=fm//(aw*100)
nb=fm//(bw*100)

ans=0
li=[]
for ia in range(na+1):
    for ib in range(nb+1):
        total_water=ia*aw*100+ib*bw*100       
        
        if total_water>fm:
            break
        if total_water==0:
            break
        
        if total_water in li:
            break
        li.append(total_water)
        
        for ic in range((((total_water//100)*ep)//cs)+1):
            for id in range((((total_water//100)*ep)//ds)+1):

                total=total_water+ic*cs+id*ds
                if total>fm:
                    break
                if (ic*cs+id*ds)/total>=ans and ic*cs+id*ds<=total_water//100*ep:
                    ans_total=total
                    ans_sugar=ic*cs+id*ds
                    ans=(ic*cs+id*ds)/total
print(ans_total,ans_sugar)

Submission status: Accepted

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

M = 0
S = 0
N = 30
ansp = 0
tmpM = 0
tmpS = 0
SUGAR = [0]*3001
SUGAR[0] = 1
for i in range(1,3001):
    if i - C >= 0:
        if SUGAR[i-C] == 1:
            SUGAR[i] = 1
    if i - D >= 0:
        if SUGAR[i-D] == 1:
            SUGAR[i] = 1

for i in range(31):
    for j in range(31-i):
        tmpM = 100*A*i+100*B*j
        maxS = E*(A*i+B*j)
        if tmpM != 0 and tmpM <= F:
            for k in range(E*(A*i+B*j)+1):
                l = E*(A*i+B*j) - k
                #print(l)
                if SUGAR[l] == 1 and l+tmpM <= F:
                    tmpS = l
                    break
            if tmpS/(tmpM+tmpS) > ansp:
                ansp = tmpS/(tmpM+tmpS)
                M = tmpM
                S = tmpS
if M != 0:
    print(*[M+S,S])
else:
    print(*[100*A,0])

Submission status: Accepted

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

limit = e / (100 + e)

mx = 0
ans = [100 * a, 0]

a_max = f // (100 * a)
for a_i in range(a_max + 1):
    ag = 100 * a * a_i
    bcdg_max = f - ag
    b_max = bcdg_max // (100 * b)
    for b_i in range(b_max + 1):
        bg = 100 * b * b_i
        if ag + bg == 0:
            continue
        cdg_max = bcdg_max - bg
        c_max = cdg_max // c
        for c_i in range(c_max + 1):
            cg = c * c_i
            dg_max = cdg_max - cg
            d_max = dg_max // d
            for d_i in range(d_max + 1):
                dg = d * d_i
                tmp = (cg + dg) / (ag + bg + cg + dg)
                if mx < tmp <= limit:
                    mx = tmp
                    ans = [ag + bg + cg + dg, cg + dg]

print(*ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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

A = A * 100
B = B * 100

ans = 0
m = (0, 0)
for i in range(int(F / A) + 1):
    for j in range(int(F / B) + 1):
        for k in range(80):
            for l in range(80):
                wa = (A * i) + (B * j)
                su = (C * k) + (D * l)

                if wa + su > F:
                    continue

                if (wa // 100 * E) < su:
                    continue

                if wa == 0:
                    continue

                t = (su * 100) / (wa + su)
                if ans <= t:
                    ans = t
                    m = (wa, su)

print(sum(m), m[1])

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c, d, e, f = list(map(int, input().rstrip('\n').split()))
    mn = 0
    x = y = 0
    for i in range(f // (a * 100) + 1):
        for j in range((f - 100 ** i) // (b * 100) + 1):
            for k in range((f - 100 * i - 100 * j) // c + 1):
                for l in range((f - 100 * i - 100 * j - k) // d + 1):
                    if 100 * i * a + 100 * j * b + c * k + d * l <= f:
                        if a * i + b * j != 0 and (c * k + d * l) / (a * i + b * j) <= e:
                            if mn < (c * k + d * l) / (100 * i * a + 100 * j * b + c * k + d * l):
                                if (100 * i * a + 100 * j * b + c * k + d * l) <= f:
                                    mn = (c * k + d * l) / (100 * i * a + 100 * j * b + c * k + d * l)
                                    x = 100 * i * a + 100 * j * b + c * k + d * l
                                    y = c * k + d * l
    if x == y == 0:
        print(a * 100, 0)
    else:
        print(x, y)



if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from math import ceil, floor

def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    
    x = []
    y = []  

    for i in range(ceil(F/(100*A))+1):
        for j in range(ceil(F/(100*B))+1):
            dx = 100*A*i+100*B*j
            if(min(100*A,100*B) <= dx <= F):
                x.append(dx)

    for i in range(ceil(F/C)+1):
        for j in range(ceil(F/C)+1):
            dy = C*i+D*j
            if(0 <= dy <= F):
                y.append(dy)

    x = sorted(list(set(x)))
    y = sorted(list(set(y)))
    
    w = x[0]
    s = y[0]

    for i in x:
        for j in y:
            de = 100*s/(w+s)
            ne = 100*j/(i+j)
            if(i+j <= F and de < ne <= 100*E/(100+E)):
                # print(i, j, ne)
                w = i
                s = j

    print(w+s, s)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

W = []
S = []
for i in range((F//A)+1):
	j = 0
	while True:
		temp =  100*A*i + 100*B*j
		if temp <= F:
			W.append(temp)
		else:
			break

		j += 1


for i in range((F//C)+1):
	j = 0
	while True:
		temp =  C*i + D*j
		if temp <= F:
			S.append(temp)
		else:
			break

		j += 1

W.pop(0)
S.pop(0)

ans = 0
ans_whole = 0
ans_sugar = 0
for w in W:
	for s in S:
		if w+s <= F and s <= (w/100)*E:
			if ans <= (100*s)/(w+s):
				ans = (100*s)/(w+s)
				ans_whole = w+s
				ans_sugar = s

if ans == 0:
	print(100*A, end = " ")
	print(0)

else:
	print(ans_whole, end= " ")
	print(ans_sugar)

Submission status: Accepted

Solution code:
A,B,C,D,E,F=map(int,input().split())
a=b=d=0
m=lambda:100*(A*a+B*b)+D*d
l=[]
while m()<=F:
 while m()<=F:
  while m()<=F:
   c=min((E*(A*a+B*b)-D*d)//C,(F-m())//C)
   if(a+b>0)&(c>=0):l+=[(m()+C*c,C*c+D*d,E-(C*c+D*d)/(A*a+B*b))]
   d+=1
  b+=1;d=0
 a+=1;b=0
l.sort(key=lambda x:x[2])
print(*l[0][:2])

Submission status: Accepted

Solution code:
import bisect

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

water = set()
for i in range(31):
    for j in range(31):
        w = i*a + j*b
        if w <= f//100:
            water.add(w)
water = sorted(water)

suger = set()
for i in range(1501):
    j = 0
    while i*c + j*d <= 1500:
        suger.add(i*c+j*d)
        j += 1
suger = sorted(suger)

ans = []
for w in water:
    sid = bisect.bisect_right(suger, w*e) - 1
    while suger[sid] + w*100 > f and sid > 0:
        sid -= 1
    if w != 0:
        total = w*100 + suger[sid]
        ans.append([suger[sid]/total, total, suger[sid]])
ans.sort(key=lambda x:x[0])
print(ans[-1][1], ans[-1][2])

Submission status: Accepted

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

ans = [0,0,0]
for i in range(maxa+1): # iはAの回数
    for j in range((f-100*a*i)//b+1):
        v = 100*a*i + 100*b*j
        if f < v: break
        maxs = min(v*e//100,f-v)
        for k in range(maxs//d+1):
            l = (maxs-d*k)//c
            s = c*l + d*k
            if v+s > f: continue
            if v/100*e < s: continue
            if v+s == 0: continue
            if ans[0] <= 100*s/(v+s):
                ans = [100*s/(v+s),v+s,s]
print(*ans[1:])

Submission status: Accepted

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

ans = [0,0,0]
for i in range(maxa+1): # iはAの回数
    for j in range((f-100*a*i)//b+1):
        v = 100*a*i + 100*b*j
        if f < v: continue
        for k in range((f-v)//d+1):
            for l in range((f-v-k*d)//c+1,-1,-1):
                s = c*l + d*k
                if v+s > f: continue
                if v/100*e < s: continue
                if v+s == 0: continue
                if ans[0] <= 100*s/(v+s):
                    ans = [100*s/(v+s),v+s,s]
                    break
print(*ans[1:])

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

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

A,B,C,D,E,F = II()

val = 0
ans1 = 100*A
ans2 = 0

for a in range(math.ceil(F/(100*A))+1):
    for b in range(math.ceil(F/(100*B))+1):
        for c in range(math.ceil((A*a+B*b)*E/C)+1):
            for d in range(math.ceil((A*a+B*b)*E/D)+1):
                if 100*(A*a+B*b)+C*c+D*d > F:
                    break
                if C*c+D*d > (A*a+B*b)*E:
                    break
                if A*a+B*b==0:
                    break
                if (C*c+D*d)/(A*a+B*b) > val:
                    val = (C*c+D*d)/(A*a+B*b)
                    ans1 = 100*(A*a+B*b)+C*c+D*d
                    ans2 = C*c+D*d

print(ans1, ans2)

Submission status: Accepted

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


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

        sousa1 = 1
        sousa2 = 0
        ans = (0, 100 * A, 0)
        while True:
            if sousa1 * 100 * A > F:
                break
            while True:
                water = sousa1 * 100 * A + sousa2 * 100 * B
                if water > F:
                    sousa2 = 0
                    break

                sugar_limit = water // 100 * E
                sousa3 = 0
                sousa4 = 0
                max_sugar = 0
                while True:
                    if sousa3 * C > sugar_limit:
                        break
                    while True:
                        sugar = sousa3 * C + sousa4 * D
                        if water + sugar > F or sugar > sugar_limit:
                            sousa4 = 0
                            break
                        else:
                            max_sugar = max(max_sugar, sugar)
                        sousa4 += 1
                    sousa3 += 1
                concentration = 100 * max_sugar / (water + max_sugar)
                if ans[0] < concentration:
                    ans = [concentration, water, max_sugar]
                sousa2 += 1
            sousa1 += 1

        print('{} {}'.format(sum(ans[1:]), ans[2]))


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

Solution code:
a,b,c,d,e,f = map(int,input().split())
xset = set()
yset = set()
for i in range(31):
  for j in range(16):
    if (a*i+b*j)*100 <= f:
      xset.add((a*i+b*j)*100)
xset.remove(0)
for i in range(f//c+1):
  for j in range(f//d+1):
    if c*i+c*j<=f:
      yset.add(c*i+d*j)
ll = []
maxconc = 0
maxsolution = 100*a
maxsolute = 0
for i in xset:
  for j in yset:
    if i+j<= f and i >= (100*j)/e and (100*j)/(i+j)>maxconc:
      maxconc = (100*j)/(i+j)
      maxsolution = i+j
      maxsolute = j
print(str(maxsolution)+' '+str(maxsolute))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
A,B,C,D,E,F=map(int,input().split())

A=A*100
B=B*100

ans=[]
water=set()

for i in range(F//(A)+1):
    for j in range((F-A*i)//B+1):
        water.add(A*i+B*j)
water.remove(0)

ans=-1
ans_all=-1
ans_sol=-1

for item in water:
    for i in range((F-item)//(C)+1):
        if C*i/item*100>E:
            break
        j=min((F-item-C*i)//D,(item*E/100-C*i)//D)
        if (C*i+D*j)/(item+C*i+D*j)>ans:
            ans_sol=C*i+D*j
            ans_all=item+ans_sol
            ans=ans_sol/ans_all
    
print(int(ans_all),int(ans_sol))

Submission status: Accepted

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

lst = []

for a in range(0, F, 100*A):
    for b in range(0, F, 100*B):
        x = a + b        
        if x == 0 or x > F:
            continue
        
        for c in range(0, F, C):
            for d in range(0, F, D):
                y = c + d
                if x + y > F or 100*y/(x+y) > 100*E/(100+E):
                    break
                lst.append((100*y/(x+y), x+y, y)) 

d, t, y = max(lst)
print(t, y)

Submission status: Accepted

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

result = [0, 0]
noude = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                water = a * 100 * i + b * 100 * j
                sugar = c * k + d * l
                if water == 0 or water + sugar > f:
                    break
                if (water / 100) * e >= sugar and noude < (100 * sugar) / (water + sugar):
                    noude = (100 * sugar) / (water + sugar)
                    result = [water + sugar, sugar]

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

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
rs = []
for a in range(0, F, 100*A):
  for b in range(0, F, 100*B):
    x = a+b
    if x == 0 or x > F:
      continue
    for c in range(0, F, C):
      for d in range(0, F, D):
        y = c+d
        if not(x+y <= F):
          break
        # if 100*y/(x+y) <= 100*E/(100+E):
        if not(y*100 <= E*x):
          break
        rs.append((100*y/(x+y), x+y, y))
c, z, y = max(rs)
print(z, y)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    A, B, C, D, E, F = map(int, input().split())
    
    mx = 0
    sugar_weight = 0
    water_weight = 0
    for a in range(F // (100 * A) + 1):
        A_w = 100 * A * a
        for b in range((F - A_w) // (100 * B) + 1):
            B_w = 100 * B * b
            for c in range((F - (A_w + B_w)) // C + 1):
                C_w = C * c
                for d in range((F - (A_w + B_w + C_w)) // D + 1):
                    D_w = D * d
                    if a == 0 and b == 0:
                        pass
                    elif C * c + D * d <= E * (A * a + B * b):
                        if mx <= (100 * (C_w + D_w)) / (A_w + B_w + C_w + D_w):
                            mx = (100 * (C_w + D_w)) / (A_w + B_w + C_w + D_w)
                            sugar_weight = C_w + D_w
                            water_weight = A_w + B_w + C_w + D_w

    print(water_weight, sugar_weight)

Submission status: Accepted

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

sugar = set()
water = set()

for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        w = 100 * A * i + 100 * B * j
        if 0 < w <= F:
            water.add(w)

for i in range(F//C + 1):
    for j in range(F//D + 1):
        s = C * i + D * j
        if s <= F:
            sugar.add(s)

ans_w = 0
ans_s = 0
conc = 0
for s in sugar:
    for w in water:
        if s + w > F:
            continue
        if s > w * E / 100:
            continue
        tmp = s / (s + w) * 100
        if tmp >= conc:
            conc = tmp
            ans_w = w
            ans_s = s

print(ans_s + ans_w, ans_s)

Submission status: Accepted

Solution code:
A, B, C, D, E, limit = map(int, input().rstrip("\n").split())

target_concent = E * 100 / (100 + E)
water_vars = {(i * A + j * B) * 100 for i in range(limit // (100 * A) + 1) for j in range(limit // (100 * B) + 1) if (i * A + j * B) * 100 <= limit}
water_vars = sorted(water_vars)[1:]

ans_solution = 0
ans_sugar = 0
max_concent = 0

break_all = False

for water in water_vars:
    sugar_limit = limit - water
    sugar_vars = {i * C + j * D for i in range(sugar_limit // C + 1) for j in range(sugar_limit // D + 1) if i * C + j * D <= sugar_limit}
    sugar_vars = sorted(sugar_vars)
    for sugar in sugar_vars:
        concent = sugar * 100 / (sugar + water)
        if concent == target_concent:
            ans_solution = water + sugar
            ans_sugar = sugar
            break_all = True
            break
        elif max_concent <= concent < target_concent:
            ans_solution = water + sugar
            ans_sugar = sugar
            max_concent = concent
        elif concent > target_concent:
            break
    if break_all:
        break

print(ans_solution, ans_sugar)

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_a = f // (100*a)
max_b = f // (100*b)
max_c = f // c
max_d = f // d
wat = []
sug = []
for i in range(max_a + 1):
    for j in range(max_b + 1):
        w = 100 * a * i + 100 * b * j
        if w <= f and w > 0:
            wat.append(w)
for i in range(max_c + 1):
    for j in range(max_d + 1):
        s = c*i + d*j
        if s < f:
            sug.append(s)
ans = 0
for x in wat:
    for y in sug:
        if x + y <= f and y <= e * x / 100:
            if ans <= 100 * y / (x + y):
                ans =  100 * y / (x + y)
                out = [x+y, y]
print(*out)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = [int(x) for x in input().split()]
 
X = []
for i in range(F // (100 * A) + 1):
	for j in range((F - 100 * A * i) // (100 * B) + 1):
		X.append(100 * A * i + 100 * B * j)
 
Y = []
for i in range(F // C + 1):
	for j in range((F - C * i) // D + 1):
		Y.append(C * i + D * j)
 
concentrationMAX = 0
ans = [100 * A,0]
 
for i in X:
	for j in Y:
		if i + j > 0:
			if i + j <= F:
				if i // 100 * E >= j:
					if j / (i + j) > concentrationMAX:
						concentrationMAX = j / (i + j)
						ans[0] = i + j
						ans[1] = j
 
print(ans[0],end=' ')
print(ans[1])

Submission status: Accepted

Solution code:
a,b,c,d,e,f=list(map(int,input().split()))
val=0
lst=[0,0]
for i in range(31):
	for j in range(31):
		for k in range(101):
			for l in range(101):
				wtr=100*i*a+100*j*b
				sgr=k*c+l*d
				if wtr==0 or wtr>f or sgr>f or wtr+sgr>f:
					break
				else:
					if sgr/(sgr+wtr)<=e/(e+100) and sgr/(sgr+wtr)>val:
						val=sgr/(sgr+wtr)
						lst[0]=sgr
						lst[1]=sgr+wtr
if lst[0]==0:
	print(100*a,0)
else:
	print(lst[1],lst[0])

Submission status: Accepted

Solution code:
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c, d, e, f = na()
m = f // (100 * a)
n = f // c
wli = []
sli = []
for i in range(m+1):
    for j in range(m+1):
        x = 100 * a * i + 100 * b * j
        if 0 < x <= f:
            wli.append(x)
for i in range(n):
    for j in range(n):
        y = c * i + d * j
        if y <= f:
            sli.append(y)
ans = [0, 0, 0]
for x in wli:
    for y in sli:
        if x + y <= f and 100 * y <= e * x:
            p = y * 100 / (x + y)
            if ans[2] <= p:
                ans = [x + y, y, p]
print(*ans[:2])

Submission status: Accepted

Solution code:
#提出 #6036238 参考
def main():
    A, B, C, D, E, F = (int(i) for i in input().split())

    WF = F//100
    water = [False] * (WF + 1)
    water[0] = True
    #30
    for n in range(WF + 1):
        if water[n]:
            if n+A <= WF: water[n+A] = True
            if n+B <= WF: water[n+B] = True

    sugar = [False] * (F + 1)
    sugar[0] = True
    #3000
    for n in range(F + 1):
        if sugar[n]:
            if n+C <= F: sugar[n+C] = True
            if n+D <= F: sugar[n+D] = True

    water = set(100*x for x in range(1,1+WF) if water[x]) #0除算を避け、かつ水の量0はありえないのでrange(1,1+WF)
    sugar = set(x for x in range(1+F) if sugar[x]) #砂糖0gでも、濃度0%の砂糖水

    max_consist = -1
    ans = (0,0)
    #at most 30*3000 
    for w in water:
        for s in sugar:
            if s <= w//100 * E and w + s <= F: #sがwに溶け残らない、かつwとsがビーカーに入り切る
                cur_consist = (100*s)/(w+s)
                if max_consist < cur_consist:
                    max_consist = cur_consist
                    ans = (w + s,s)

    print(*ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

    water = set()
    for a in range(0,F+1,100*A):
        for b in range(0,F+1,100*B):
            if a + b != 0 and a+b <= F:
                water.add(a+b)

    max_consist = 0
    ans = (0,0)
    for w in water:
        ab = w //100
        sugar_max = E * ab
        x = sugar_max // C
        y = sugar_max // D
        s = max(C*i + D*j for i in range(x+1) for j in range(y+1) if C*i + D*j <= sugar_max and w + C*i + D*j <= F)
        if w + s <= F:
            cur_consist = (100*s)/(w+s)
            if max_consist <= cur_consist:
                max_consist = cur_consist
                ans = (w + s,s)

    print(*ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
ans = [0,0]
maxconc = -1
for i in range(31):
    for j in range(31):
        water = A*i + B*j
        if 100 * water > F:continue
        loopk = E*water // C + 1
        
        for k in range(loopk):
            loopl = (E*water-C*k)// D + 1
            for l in range(loopl):
                sugar = C*k + D*l
                if 100*water + sugar > F or 100*water + sugar == 0:continue
                if sugar <= water * E:
                    conc = (sugar)/(sugar+100*water)
                    if conc > maxconc:
                        ans = [100*water+sugar,sugar]
                        maxconc = conc
                    
print(*ans)

Submission status: Accepted

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

S = [0] * 1501
for i in range(1500//c + 1):
    for j in range(1500//d + 1):
        if c * i + d * j <= 1500:
            S[c * i + d * j] = 1

S2 = [0] * 1501
t = 0
for i in range(1501):
    if S[i] == 1:
        t = i
    S2[i] = t

#print(S2[:100])

ans = [0, 0, 0]
for i in range(30):
    for j in range(30):
        water = i * 100 * a + j * 100 * b
        if 0 < water <= f:
            sugar_max = min(f - water, water * e * 0.01)
            sugar = S2[int(sugar_max)]
            noudo = sugar / (water + sugar)
            #print(i, j, water, sugar_max, sugar, noudo)
            if noudo >= ans[0]:
                #print(i, j, sugar)
                ans[0] = noudo
                ans[1] = water + sugar
                ans[2] = sugar

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc074/tasks/arc083_a
# C - Sugar Water
import math
w_A, w_B, s_C, s_D, limit_E, max_F = list(map(int, input().split()))

# それ以上溶かすことができるか
# それ以上重量を増やせるか

# 取りうる水の組み合わせ
w_A_list = [w_A * x * 100 for x in range(math.floor(max_F / (w_A * 100)) + 1)]
w_B_list = [w_B * x * 100 for x in range(math.floor(max_F / (w_B * 100)) + 1)]

# 最悪で3000*3000
w_list = []
for a in w_A_list:
    for b in w_B_list:
        if a + b <= max_F:
            w_list.append(a + b)
w_list = list(set(w_list))  # 3000以下

# 取りうる水の組み合わせ
s_C_list = [s_C * x  for x in range(math.floor(max_F / s_C) + 1)]
s_D_list = [s_D * x  for x in range(math.floor(max_F / s_D) + 1)]

# 最悪で3000*3000
s_list = []
for c in s_C_list:
    for d in s_D_list:
        if c + d <= max_F:
            s_list.append(c + d)
s_list = list(set(s_list))  # 3000以下

max_d = -float('inf')
for w in w_list:
    for s in s_list:
        limit_s = w * limit_E / 100
        if w + s <= max_F and w + s != 0 and s <= limit_s:
            d = (s / (w + s)) * 100
            if d > max_d:
                max_d = d
                ans_ws, ans_s = w + s, s

ans = ' '.join([str(ans_ws), str(ans_s)])
print(ans)

Submission status: Accepted

Solution code:
ans=[]
a,b,c,d,e,f=map(int,input().split())
for i in range(31):
	for j in range(16):
		for k in range(101):
			for l in range(51):
				if (i*a+j*b)*100+(c*k+d*l)<=f and \
				c*k+d*l<=e*(i*a+j*b):
					p=c*k+d*l
					q=p+100*(i*a+j*b)
					if 100*(i*a+j*b)!=0:
						ans.append([100*p/q,p,q])
ans.sort()
print(ans[-1][2],ans[-1][1])

Submission status: Accepted

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

a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
ans_total = 100*A
ans_sugar = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
      max_dens = dens
      ans_total = total
      ans_sugar = j
            
print(ans_total, ans_sugar)

Submission status: Accepted

Solution code:
import math
A,B,C,D,E,F = map(int,input().split())
water = []
for i in range(math.floor(F/(100*A))+1):
    M = 100*A*i
    while M <= F:
        if M not in water and M != 0:
            water.append(M)
        M += 100*B
def max_dens(w):
    max_s = min(F-w,w*E/100)
    max_d = 0
    for i in range(math.floor(max_s/D)+1):
        sugar = math.floor((max_s-i*D)/C)*C+i*D
        max_d = max(max_d,sugar)
    return max_d
den = [max_dens(x)/x for x in water]
index = den.index(max(den))
print(water[index]+max_dens(water[index]),max_dens(water[index]))