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:
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a,b,c,d,e,f = map(int,readline().split())
wf = f//100+1
water = [0]*(wf+31)
suger = [0]*(f+31)

water[0] = 1
suger[0] = 1

for i in range(wf):
    if water[i]:
        water[i+a] = 1
        water[i+b] = 1
for i in range(f):
    if suger[i]:
        suger[i+c] = 1
        suger[i+d] = 1

water = set(100*i for i in range(1,wf+1) if water[i])
suger = set(i for i in range(f+1) if suger[i])

ans_per = -1
ans_water = 0
ans_suger = 0

for w,s in itertools.product(water,suger):
    if w//100*e < s: #砂糖が溶け残る
        continue
    if w+s > f: #重量オーバー
        continue
    res = s/(w+s) #パーセンテージ
    if res > ans_per:
        ans_per = res
        ans_water = w
        ans_suger = s

print(ans_water+ans_suger,ans_suger)

Submission status: Accepted

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

A*=100
B*=100

dp=[-1 for i in range(F+1)]
dp2=[-1 for i in range(F+1)]
dp[0]=0
dp2[0]=0


for i in range(1,len(dp)):
    if i>=C and dp[i-C]>=0 or i>=D and dp[i-D]>=0:
        dp[i]=i
for i in range(1,len(dp)):
    if i>=A and dp2[i-A]>=0 or i>=B and dp2[i-B]>=0:
        dp2[i]=i
#print(dp)
#print(dp2)

noud=0
rep1=0
redp2=0
saidainoudo=E/(E+100)
for p1 in dp:
    if p1!=-1:
        for p2 in dp2:
            if p2>=0:

                satousui=p1+p2
                if 0<satousui<=F:
                    tempnoud=p1/(satousui)

                    if noud<tempnoud<=saidainoudo:
                        #print(p1,p2)
                        noud=tempnoud
                        rep1=p1
                        redp2=satousui
if rep1>0:
    print(redp2,rep1)
else:
    print(A,0)

Submission status: Accepted

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
a_count = 0
b_count = 0
c_count = 0
d_count = 0
max_per = 0.0
max_ans = [a*100,0]
while a_count * 100 * a <= f:
    b_count = 0
    c_count = 0
    d_count = 0
    while (a_count * a + b_count * b) * 100  <= f:
        c_count = 0
        d_count = 0
        while (a_count * a + b_count * b) * 100 + c_count * c <= f:
            d_count = 0
            while (a_count * a + b_count * b) * 100 + c_count * c + d_count * d <= f:
                #溶けてるのかどうか
                if (a_count * a + b_count * b)* e < (c_count * c + d_count * d):
                    break
                else:
                    if a_count + b_count + c_count + d_count == 0:
                        break
                    if max_per < (100 * (c_count * c + d_count * d) / ((a_count * a + b_count * b) * 100 + c_count * c + d_count * d)):
                        max_ans = [(a_count * a + b_count * b) * 100 + c_count*c + d_count*d, c_count*c + d_count * d]
                        max_per = (100 * (c_count * c + d_count * d) / ((a_count * a + b_count * b) * 100 + c_count * c + d_count * d))
                d_count += 1
            c_count += 1
        b_count += 1
    a_count += 1
print("{} {}".format(max_ans[0], max_ans[1]))

Submission status: Accepted

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

water = set()
for i in range(0, f+1, 100*a):
    for j in range(0, f+1, 100*b):
        water.add(i+j)
water.remove(0)

sugar = set()
for i in range(0, f+1, c):
    for j in range(0, f+1, d):
        sugar.add(i+j)

best_w = best_s = best_dens = -1
for w in sorted(water):
    for s in sorted(sugar):
        if w + s > f:
            break
        if w * e < s * 100:
            break
        density = s / (s + w)
        if density > best_dens:
            best_w = w
            best_s = s
            best_dens = density

print(best_w + best_s, best_s)

Submission status: Accepted

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


dp = [0 for i in range(f//100+1)]
dp[0] = 1
for i in range(f//100+1):
    if dp[i]:
        if i + a <= f//100:
            dp[i+a] = 1
        if i + b <= f//100:
            dp[i+b] = 1
dd = [0 for i in range(f+1)]
dd[0] = 1
for i in range(f+1):
    if dd[i]:
        if i + c <= f:
            dd[i+c] = 1
        if i + d <= f:
            dd[i+d] = 1

water = [i for i in range(1,f//100+1) if dp[i]]
sugar = [i for i in range(f+1) if dd[i]]
ans = -1
ww, ss= 0,0
for w in water:
    for s in sugar:
        if w*100+s <= f and e*w >= s:
            if ans < 100 * s / (100*w+s):
                ans = 100*s / (w*100+s)
                ww,ss=w*100,s

print(ww+ss,ss)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    A, B, C, D, E, F = [int(x) for x in input().split()]

    b = [False] * 31
    b[A] = True
    b[B] = True

    for i, v in enumerate(b):
        if v:
            if i + A <= 30:
                b[i + A] = True
            if i + B <= 30:
                b[i + B] = True

    sugar = [False] * 3001
    sugar[C] = True
    sugar[D] = True

    for i, v in enumerate(sugar):
        if v:
            if i + C <= 3000:
                sugar[i + C] = True
            if i + D <= 3000:
                sugar[i + D] = True

    ans1 = A * 100
    ans2 = 0

    for i, v in enumerate(b):
        if v:
            for j, s in enumerate(sugar):
                if s:
                    if ans2 / (ans1 + ans2) < j / (i * 100 + j) <= E / (100 + E) and i * 100 + j <= F:
                        ans1 = i * 100
                        ans2 = j

    print(ans1 + ans2, ans2)





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
waterset = set()
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        water = (A*i + B *j)*100
        if water < F:
            waterset.add(water)
waterset.remove(0)
sugarset = set()
for i in range(F//C + 1):
    for j in range(F//D + 1):
        sugar = C*i + D*j
        if sugar < F:
            sugarset.add(sugar)
best_conc = -1
best_a = -1
best_b = -1
for a in waterset:
    for b in sugarset:
        if a+b >F:
            continue
        if b * 100 > E*a:
            continue
        conc = 100*b/(a+b)
        if conc > best_conc:
            best_conc = conc
            best_a = a
            best_b = b
print(best_a+best_b,best_b)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
waterset = set()
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        water = (A*i + B *j)*100
        if water < F:
            waterset.add(water)
waterset.remove(0)
sugarset = set()
for i in range(F//C + 1):
    for j in range(F//D + 1):
        sugar = C*i + D*j
        if sugar < F:
            sugarset.add(sugar)
best_conc = -1
best_a = -1
best_b = -1
for a in waterset:
    for b in sugarset:
        if a+b >F:
            continue
        if b/a > E/100:
            continue
        conc = 100*b/(a+b)
        if conc > best_conc:
            best_conc = conc
            best_a = a
            best_b = b
print(best_a+best_b,best_b)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
waterset = set()
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        water = (A*i + B *j)*100
        if water < F:
            waterset.add(water)
waterset.remove(0)
sugarset = set()
for i in range(F//C + 1):
    for j in range(F//D + 1):
        sugar = C*i + D*j
        if sugar < F:
            sugarset.add(sugar)
best_conc = -1
best_a = -1
best_b = -1
for a in waterset:
    for b in sugarset:
        if a+b >F:
            continue
        if b > E*a/100:
            continue
        conc = 100*b/(a+b)
        if conc > best_conc:
            best_conc = conc
            best_a = a
            best_b = b
print(best_a+best_b,best_b)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
waterset = set()
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        water = (A*i + B *j)*100
        if water < F:
            waterset.add(water)
waterset.remove(0)
sugarset = set()
for i in range(F//C + 1):
    for j in range(F//D + 1):
        sugar = C*i + D*j
        if sugar < F:
            sugarset.add(sugar)
best_conc = -1
best_a = -1
best_b = -1
for a in waterset:
    for b in sugarset:
        if a+b >F:
            continue
        if b > E*a//100:
            continue
        conc = 100*b/(a+b)
        if conc > best_conc:
            best_conc = conc
            best_a = a
            best_b = b
print(best_a+best_b,best_b)

Submission status: Accepted

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

ans_t=0
ans_s=0
for a in range(0,F+1,A):
    for b in range(0,F-a+1,B):
        w=a+b
        if w==0: continue
        for c in range(0,F-w+1,C):
            for d in range(0,F-w-c+1,D):
                s=c+d
                t=w+s
                if w*E<s*100: break
                if ans_s*t<=s*ans_t:
                    ans_t=t
                    ans_s=s

print(ans_t,ans_s)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="number"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True

 

 
#main
A,B,C,D,E,F=map(int,input().split())
A*=100
B*=100
mizu=[]
satou=[]

for a in range(0,F+1,A):
    for b in range(0,F+1,B):
        mizu.append(a+b)
for a in range(0,F+1,C):
    for b in range(0,F+1,D):
        satou.append(a+b)

mizu.sort()
satou.sort()

ans=None

for a in satou:
    for b in mizu:
        s=a+b
        if(s==0):continue
        if(s>F):break
        if(a*100>E*b):continue
        if(ans==None):ans=[a,s]
        if(a*ans[1]>ans[0]*s):
            ans=[a,s]

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

Submission status: Accepted

Solution code:
A,B,C,D,E,F=map(int,input().split())
# 作れる水の量をDPで求める (MAXはF)
# 作れる砂糖の量をDPで求める　（MAXは、F*(E/(E+100)）
# 作れる水の量に対して二分探索で、最も多く入れられる砂糖の量を求める。

dpW=[False]*(F+1)
dpW[0]=True
for w in (A*100,B*100):
  for j in range(len(dpW)):
    if dpW[j] and j+w<len(dpW):
      dpW[j+w]=True
      
water=[]
for i in range(len(dpW)):
  if dpW[i] and i!=0:
    water.append(i)

maxsugar=int(F*(E/(E+100)))+1
dpS=[False]*(maxsugar+1)
dpS[0]=True
for s in (C,D):
  for j in range(len(dpS)):
    if dpS[j] and j+s<len(dpS):
      dpS[j+s]=True
sugar=[]
for i in range(len(dpS)):
  if dpS[i]:
    sugar.append(i)
    
ans=[0,0]
maxrate=0
for w in water:
  maxS=int(w*(E/100))
  if w+maxS>F:
    maxS=F-w
  # maxSを越えない最大の砂糖をsugarから探す
  ok=0
  ng=len(sugar)
  while abs(ok-ng)>1:
    mid=abs(ok+ng)//2
    if sugar[mid]<=maxS:
      ok=mid
    else:
      ng=mid
  if sugar[ok]/w>=maxrate:
    maxrate=sugar[ok]/w
    ans=[w+sugar[ok],sugar[ok]]
print(*ans)

Submission status: Accepted

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range((t - C * i) // D + 1):
        s.add(C * i + D * j)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

w = set()
for i in range(F // (100 * A) + 1):
    t = F - 100 * A * i
    for j in range(t // (100 * B) + 1):
        a = (A * i + B * j) * 100
        w.add(a)
w.remove(0)

s = set()
t = E * F // 100
for i in range(t // C + 1):
    u = t - C * i
    for j in range(u // D + 1):
        b = C * i + D * j
        s.add(b)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

w = set()
for i in range(F // (100 * A) + 1):
    t = F - 100 * i
    for j in range(t // (100 * B) + 1):
        a = (A * i + B * j) * 100
        w.add(a)
w.remove(0)

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < t:
            s.add(b)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

Solution code:
a,b,c,d,e,f = map(int,input().split())
w = []
for i in range(f//100//a+1):
    for j in range(f//100//b+1):
        w.append(i*100*a + j*100*b)
w = set(w)
s = []
for i in range(f//c+1):
    for j in range(f//d+1):
        s.append(i*c + j*d)
s = set(s)
ans = []
for i in w:
    for j in s:
        if i != 0 and j/(i+j) <= e/(100+e) and i+j <= f:
            ans.append([j/(i+j), j+i, j])
ans.sort()
print(ans[-1][1], ans[-1][2])

Submission status: Accepted

Solution code:
a,b,c,d,e,f = map(int,input().split())
w = []
for i in range(f//100//a+1):
    for j in range(f//100//b+1):
        if (i*a + j*b)*100 <= f:
            w.append(i*100*a + j*100*b)
w = set(w)
w.remove(0)
s = []
for i in range(e*f//100//c+1):
    for j in range(e*f//100//d+1):
        if i*c + j*d <= e*f//100:
            s.append(i*c + j*d)
s = sorted(set(s))

ans = []
for i in w:
    for j in s:
        if i != 0 and j <= e* i//100 and i+j <= f:
            ans.append([j/(i+j), j+i, j])
ans.sort()
print(ans[-1][1], ans[-1][2])

Submission status: Accepted

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < t:
            s.add(b)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    t = min(F - a, E * a // 100)
    for i in range(t // C + 1):
        for j in range(t // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

Solution code:
from bisect import bisect_right

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < t:
            s.add(b)
s = list(s)
s.sort()

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    i = bisect_right(s, min(E * a // 100, F - a))
    if i == 0:
        continue
    b = s[i - 1]
    concentration = 100 * b / (a + b)
    if concentration > best_concentration:
        best_concentration = concentration
        best_a = a
        best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < t:
            s.add(b)
s = list(s)
s.sort()

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in s:
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

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

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < F:
            s.add(b)
s = list(s)
s.sort()

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in s:
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in s:
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in s:
        if a + b > F:
            continue
        if b > E * a // 100:
            continue
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

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

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for i in range((F - a) // C + 1):
        for j in range((F - a) // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

w = []
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = (A * i + B * j) * 100
        if a < F:
            w.append(a)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for i in range((F - a) // C + 1):
        for j in range((F - a) // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            if a + b == 0:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

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

w = []
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = (A * i + B * j) * 100
        if a < F:
            w.append(a)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    t = min(F - a, E * a // 100)
    for i in range(t // C + 1):
        for j in range(t // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            if a + b == 0:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = set()
sugar = set()
answer = 0.0
answer1 = [0, 0]
w, s = 0, 0
i = 0
while True:
    j = 0
    if 100 * A * i + 100 * B * j > F:
        break
    while True:
        w = 100 * A * i + 100 * B * j
        if w > F:
            break
        water.add(w)
        j += 1
    i += 1

i = 0
while True:
    j = 0
    if C * i + D * j > F:
        break
    while True:
        s = C * i + D * j
        if s > F:
            break
        sugar.add(s)
        j += 1
    i += 1

# print(water)
# print(sugar)

for i in water:
    for j in sugar:
        # print('i:{0}, j:{1}'.format(i, j))
        if i != 0:
            if E / 100 >= j / i and F >= i + j:
                if answer <= j / i:
                    answer = j / i
                    answer1 = i + j, j
                    # print('i:{0}, j:{1}, answer:{2}'.format(i, j, answer))

print(*answer1)

Submission status: Accepted

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

water = set()
sugar = set()
res = {}
noudo = []

counter = max([int(F / A), int(F / B)])
A_counter = int(F / (A * 100))
B_counter = int(F / (B * 100))
for i in range(A_counter + 1):
    for j in range(B_counter + 1):
        tmp = A * i * 100 + B * 100 * j
        if tmp <= F:
            water.add(tmp)

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

water.remove(0)
# sugar.remove(0)

for w in water:
    for s in sugar:
        if w + s <= F and s <= E * (w / 100):
            n = s / (w + s)
            noudo.append(n)
            res[n] = {"satoumizu": w + s, "sugar": s}
ans = res[max(noudo)]
# print(" ".join([str(ans["satoumizu"]), str(ans["sugar"])]))
print(str(ans["satoumizu"]) + " " + str(ans["sugar"]))

Submission status: Accepted

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

W = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))
S = [max([c*C + d*D for c in range(int((E*w / 100) / C) + 1) for d in range(int((E*w / 100) / D) + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]
print(100*A if W[I] == 0 else W[I] + S[I], S[I])

Submission status: Accepted

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

ans = 0
sub = [0,0]

for i in range(31):
    for g in range(31):
        water = 100*a*i+100*b*g
        if water<=f and water!=0:
            r1 = f-water
            r2 = e*water//100
            _min = min(r1,r2)
            repeat_c = _min//c
            max_sugar = 0
            for m in range(repeat_c+1):
                n=(_min-c*m)//d
                if n>=0:
                    max_sugar = max(max_sugar,c*m+d*n)
            if ans<=max_sugar/(max_sugar+water):
                ans = max_sugar/(max_sugar+water)
                sub[0]=max_sugar+water
                sub[1]=max_sugar
print(*sub)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = list(map(int, input().split()))
consentration_max = 0
suger_water_max = 0
suger_max = 0
for A_cnt in range(0, 31):
    for B_cnt in range(0, 31):
        water = A_cnt * 100 * A + B_cnt * 100 * B
        if water > F or water <= 0:
            continue
        max_solt = int(E*water/100)
        for C_cnt in range(0, int(max_solt/C)+1):
            for D_cnt in range(0, max(int((max_solt - C_cnt*C)/D) + 1, 1)):
                suger = C_cnt * C + D_cnt * D
                consentration = suger/(water+suger)
                if consentration_max <= consentration and (water+suger) <= F:
                    consentration_max = consentration
                    suger_water_max = water+suger
                    suger_max = suger
print("{} {}".format(suger_water_max, suger_max))

Submission status: Accepted

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

X = set([])
Y = set([])

ans = (-1, 0, 0)
for w1 in range(0, F+1, 100*A):
    for w2 in range(0, F-w1+1, 100*B):
      w = w1+w2  # 水
      for s1 in range(0, min(F-w+1, w//100*E+1), C):
        for s2 in range(0, min(F-w-s1+1, w//100*E-s1+1), D):
          s = s1+s2  # 砂糖
          a = w+s
          ans = max(ans, (s/a if a!=0 else -1, a, s))
print(ans[1], ans[2])

Submission status: Accepted

Solution code:
from itertools import product
A, B, C, D, E, F = map(int, input().split())
ans = (-1, 0, 0)
for w1 in range(0,F+1,100*A):
    for w2 in range(0,F-w1+1,100*B):
        w = w1+w2
        for s1 in range(0,min(F-w+1,w//100*E+1),C):
            for s2 in range(0,min(F-w-s1+1,w//100*E-s1+1),D):
                s = s1+s2
                a = w+s
                ans = max(ans, (s/a if a!=0 else -1, a, s))
print(ans[1], ans[2])