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: Runtime Error

Solution code:
a,b,c,d,e,f = map(int, input().split())
max_a = a * 100 * e * 10 ** (-2)
max_b = b * 100 * e * 10 ** (-2)
 
sugar_a = []
sugar_b = []
for i in range(1501):
    for j in range(1501):
        sugar_check = c * i + d * j
        if a * 100 + sugar_check <= f:
            sugar_a.append(sugar_check)
        if b * 100 + sugar_check <= f:
            sugar_b.append(sugar_check)
            
sugar_sort_a = sorted(list(set(sugar_a)))
sugar_sort_b = sorted(list(set(sugar_b)))
 
from bisect import bisect_left,bisect_right
sugar_max_a = sugar_sort_a[bisect_right(sugar_sort_a, max_a)-1]
a_check = sugar_max_a / (a* 100 + sugar_max_a)
 
sugar_max_b = sugar_sort_b[bisect_right(sugar_sort_b, max_b)-1] 
b_check = sugar_max_b / (b*100 + sugar_max_b)
 
if a_check >= b_check:
    print(a*100+sugar_max_a, sugar_max_a)
else:
    print(b*100+sugar_max_b, sugar_max_b)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int, input().split())
max_a = a * 100 * e * 10 ** (-2)
max_b = b * 100 * e * 10 ** (-2)

sugar_a = []
sugar_b = []
for i in range(100):
    for j in range(100):
        sugar_check = c * i + d * j
        if a * 100 + sugar_check <= f:
            sugar_a.append(sugar_check)
        if b * 100 + sugar_check <= f:
            sugar_b.append(sugar_check)
            
sugar_sort_a = sorted(list(set(sugar_a)))
sugar_sort_b = sorted(list(set(sugar_b)))

from bisect import bisect_left,bisect_right
sugar_max_a = sugar_sort_a[bisect_right(sugar_sort_a, max_a)-1]
a_check = sugar_max_a / (a* 100 + sugar_max_a)

sugar_max_b = sugar_sort_b[bisect_right(sugar_sort_b, max_b)-1] 
b_check = sugar_max_b / (b*100 + sugar_max_b)

if a_check >= b_check:
    print(a*100+sugar_max_a, sugar_max_a)
else:
    print(b*100+sugar_max_b, sugar_max_b)

Submission status: Runtime Error

Solution code:
#074-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
w1,w2,s1,s2,c,lim=IL()
l=[]
for i in range(31):
    for j in range(31):
        w=w1*i*100+w2*j*100
        if w<lim:
            l.append(w)
ans_c=0
for w in l:
    maxs=min(c*w//100,lim-w)
    maxs1=maxs//s1+1
    maxs2=maxs//s2+1
    for i in range(maxs1+1):
        for j in range(maxs2+1):
            s=s1*i+s2*j
            if s+w!=0:
                if s+w<=lim and s<=maxs and ans_c<100*s/(s+w):
                    ans_c=100*s/(s+w)
                    ans=[s+w,s]
print(ans[0],ans[1])

Submission status: Runtime Error

Solution code:
import itertools
Wa,Wb,Ga,Gb,Cmax,Gmax = list(map(int,input().split()))

W = []
G = []

i = -1
while Wa*i*100<=Gmax:
  i += 1
  j = 0
  while Wa*i*100+Wb*j*100<=Gmax:
    W.append(Wa*i*100+Wb*j*100)
    j += 1

i = -1
while Ga*i<=Gmax:
  i += 1
  j = 0
  while Ga*i+Gb*j<=Gmax:
    G.append(Ga*i+Gb*j)
    j += 1

W = sorted(list(set(W)),reverse=True) 
G = sorted(list(set(G)),reverse=True) 
W.sort()

ans = 0
tmp = 0
for i in W:
  for j in G:
    if i+j<=Gmax and j*100/i<=Cmax:
      if tmp < j*100/i:
        tmp = j*100/i
        ans = str(i+j)+" "+str(j)

print(ans)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
sugar=f*e/(e+100)
water=f*100/(e+100)
p=int(sugar//c if c<d else sugar//d)
q=int(water//(100*a) if a<b else water//(100*b))
ans=0
for s in range(q+1):
  try:
    for t in range(q-s+1):
      for r in range(p+1):
        for u in range(p-r+1):
          x=100*(s*a+t*b)/((s*a+t*b)+100*(r*c+u*d))
          if x>ans and x!=100:
            ansx=s*a+t*b+r*c+u*d
            ansy=r*c+u*d
            ans=x
  except:
    continue
print(ansx,ansy)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int,input().split())
 
syokuen=[0]
 
if c == 1 or d == 1:
  for i in range(1500+1):
    syokuen.append(i)
else:
  for i in range(1500//a+1):
    for j in range(1500//b+1):
      if c*i+d*j not in syokuen and c*i+d*j <=1500 :
        syokuen.append(c*i+d*j) 
 
mizu=[0]
for i in range(30):
  for j in range(30):
      if a*i*100 + b*j*100 not in mizu and a*i*100 + b*j*100<=f:
        mizu.append(a*i*100 + b*j*100)
        
noudo_max = 0.0

for i in range(len(syokuen)):
  for j in range(len(mizu)):
    if mizu[j]+syokuen[i] != 0:
      noudo = syokuen[i]/(mizu[j]+syokuen[i])
      if mizu[j]+syokuen[i] <= f and noudo <= e/(100+e) and noudo > noudo_max:
        noudo_max = noudo
        ans_syokuen = syokuen[i]
        ans_mizu = mizu[j]
 
print(ans_syokuen+ans_mizu,ans_syokuen)

Submission status: Runtime Error

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

syokuen=[]

for i in range(1500//a):
  for j in range(1500//b):
    if c*i+d*j not in syokuen and c*i+d*j <=1500 :
      syokuen.append(c*i+d*j) 

mizu=[]
for i in range(30):
  for j in range(30):
      if a*i*100 + b*j*100 not in mizu and a*i*100 + b*j*100<=f:
        mizu.append(a*i*100 + b*j*100)
        
noudo_max = 0.0
for i in range(len(syokuen)):
  for j in range(len(mizu)):
    if mizu[j]+syokuen[i] != 0:
      noudo = syokuen[i]/(mizu[j]+syokuen[i])
      if mizu[j]+syokuen[i] <= f and noudo <= e/(100+e) and noudo > noudo_max:
        noudo_max = noudo
        ans_syokuen = syokuen[i]
        ans_mizu = mizu[j]

print(ans_syokuen+ans_mizu,ans_syokuen)

Submission status: Runtime Error

Solution code:
import bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def concentrate(water, sugar):
    if water+sugar == 0:
        return 0
    else:
        return sugar/(water+sugar)


A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water_list = []
sugar_list = []

max_cont = E/(E+100)

max_water = F//B+1
for i in range(max_water):
    remain = F - B*i
    if remain < 0:
        break
    else:
        j = remain//A
        for k in range(j+1):
            water_list.append(A*k+B*i)

max_sugar = F//D
for i in range(max_sugar):
    tmp = D*i
    remain = F - tmp
    if remain < 0:
        break
    else:
        j = remain//C
        for k in range(j+1):
            sugar_list.append(D*i+C*k)

water_list = sorted(set(water_list))
sugar_list = sorted(set(sugar_list))
print(water_list)

max_tmp = 0
ans = []
for water in water_list:
    for sugar in sugar_list:
        if water+sugar > F:
            break
        else:
            conc = concentrate(water, sugar)
            if conc > max_cont:
                break
            else:
                if max_tmp < conc:
                    max_tmp = conc
                    ans = [water, sugar]
print(sum(ans), ans[1])

Submission status: Runtime Error

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

ans_con = 0
max_con = E/(100+E)*100

a = 0
while F > 100*A*a:
    b = 0
    while F-100*A*a > 100*B*b:
        c = 0
        while F-100*(A*a+B*b) > C*c and c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//D)
            mass = water + sugar
            if mass != 0:
                con = sugar/mass*100
                if ans_con < con <= max_con:
                    ans_con = con
                    ans_mass = mass
                    ans_sugar = sugar
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

Submission status: Runtime Error

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

ans_con = 0
max_con = E/(100+E)*100

a = 0
while F > 100*A*a:
    b = 0
    while F-100*A*a > 100*B*b:
        c = 0
        while F-100*(A*a+B*b) > C*c and c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//D)
            mass = water + sugar
            if mass == 0 or mass > F:
                break
            con = sugar/mass*100
            if ans_con < con <= max_con:
                ans_con = con
                ans_mass = mass
                ans_sugar = sugar
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

Submission status: Runtime Error

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

water = []
for i in range(31):
    for j in range(31):
        if i >= 1 or j >= 1:
            if ((100*a*i + 100*b*j) + (100*a*i + 100*b*j)//100*e) <= f:
                water.append(100*a*i + 100*b*j)
                
water = list(set(water))
water.sort()

WS = []
for k in range(len(water)):
    maxp = -float('inf')
    for i in range(water[k]+1):
        for j in range(water[k]+1):
            if i >= 1 or j >= 1:
                if c*i + d*j <= water[k]//100*e:
                    suger = c*i + d*j
                    if maxp < (100*suger)/(water[k]+suger):
                        maxp = (100*suger)/(water[k]+suger)
                        ws = [maxp,water[k],suger]

    WS.append(ws)
                    
WS.sort(reverse=True)
if not WS:
    print(a*100,0)
else:
    print(WS[0][1] + WS[0][2], WS[0][2])

Submission status: Runtime Error

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

if min(a,b) >= f//100:
    print(min(a,b)*100,0)
    exit()

water = []
for i in range(31):
    for j in range(31):
        if i >= 1 or j >= 1:
            if ((100*a*i + 100*b*j) + (100*a*i + 100*b*j)//100*e) <= f:
                water.append(100*a*i + 100*b*j)
                
water = list(set(water))
water.sort()

WS = []
for k in range(len(water)):
    maxeach = -float('inf')
    for i in range(water[k]+1):
        for j in range(water[k]+1):
            if i >= 1 or j >= 1:
                if c*i + d*j <= water[k]//100*e:
                    suger = c*i + d*j
                    if maxeach < (100*suger)/(water[k]+suger):
                        maxeach = (100*suger)/(water[k]+suger)
                        ws = [maxeach,water[k],suger]

    WS.append(ws)
                    
WS.sort(reverse=True)
print(WS[0][1] + WS[0][2], WS[0][2])

Submission status: Runtime Error

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

water = []
for i in range(31):
    for j in range(31):
        if i >= 1 or j >= 1:
            if ((100*a*i + 100*b*j) + (100*a*i + 100*b*j)//100*e) <= f:
                water.append(100*a*i + 100*b*j)

water = list(set(water))
water.sort()

WS = []
for k in range(len(water)):
    maxeach = -float('inf')
    for i in range(water[k]+1):
        for j in range(water[k]+1):
            if i >= 1 or j >= 1:
                if c*i + d*j <= water[k]//100*e:
                    suger = c*i + d*j
                    if maxeach < (100*suger)/(water[k]+suger):
                        maxeach = (100*suger)/(water[k]+suger)
                        ws = [maxeach,water[k],suger]
    WS.append(ws)

WS.sort(reverse=True)
print(WS[0][1] + WS[0][2], WS[0][2])

Submission status: Runtime Error

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

water = []
for i in range(31):
    for j in range(31):
        if i >= 1 or j >= 1:
            if ((100*a*i + 100*b*j) + (100*a*i + 100*b*j)//100*e) <= f:
                water.append(100*a*i + 100*b*j)
            
water = list(set(water))
water.sort()

smax = []
for i in range(len(water)):
    suger = -float('inf')
    for j in range(water[i]+1):
        for k in range(water[i]+1):
            if j >= 1 or k >= 1:
                if c*j + d*k <= water[i]//100*e:
                    suger = max(suger, c*j + d*k)

    smax.append([(suger*100)/(water[i] + suger),water[i],suger])
    
smax.sort(reverse=True)
print(smax[0][1] + smax[0][2], smax[0][2])

Submission status: Runtime Error

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

water = []
for a in range(31):
    for b in range(31):
        if a * A + b * B <= F:
            water.append(a * A + b * B)
water = list(set(water))
water.remove(0)

sugar = []

for c in range(3001):
    for d in range(3001):
        if c * C + d * D <= F:
            sugar.append(c * C + d * D)
sugar = list(set(sugar))
sugar.remove(0)

memo = []
for w in water:
    for s in sugar:
        if w + s <= F and s/w <= E/100:
            memo.append([s/(s+a),w+s, s])
memo.sort(reverse=True)
print(memo[0][1], memo[0][2])

Submission status: Runtime Error

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

water = []
suger = []
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 100*a*i + 100*b*j <= f and 100*a*i + 100*b*j not in water:
            water.append(100*a*i+100*b*j)

for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j not in suger:
            suger.append(c*i+d*j)
max = 0
maxs = []
for w in water:
    for s in suger:
        if w+s > 0 and w//100*e >= s and w + s <= f and max < s/(w+s):
            max = s/(w+s)
            maxs = [w,s]

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

Submission status: Runtime Error

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

waterlist=[]
for i in range(0,f+100*a,100*a):
  for j in range(0,f+100*b,100*b):
    if i+j <=f:
      waterlist+=[i+j]
waterlist=list(set(waterlist))
#print(x)

sugarlist=[]
for i in range(int(f/c)+1):
  for j in range(int(f/d)+1):
    if c*i+d*j <=f:
      sugarlist+=[c*i+d*j]
sugarlist=list(set(sugarlist))
#print(y)

density=0
ans1=101
ans=1
for i in range(len(waterlist)):
  for j in range(len(sugarlist)):
    if 0 < waterlist[i]+sugarlist[j] <= f and sugarlist[j]<=waterlist[i]/100*e:
      tmp=sugarlist[j]/(waterlist[i]+sugarlist[j])
      if density < tmp:
        density = tmp
        ans1=waterlist[i]+sugarlist[j]
        ans2=sugarlist[j]
        
print(ans1,ans2)

Submission status: Runtime Error

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

waterlist=[]
for i in range(int(f/100/a)+1):
  for j in range(int(f/100/b)+1):
    if 100*a*i+100*b*j <=f:
      waterlist+=[100*a*i+100*b*j]
waterlist=list(set(waterlist))
#print(x)

sugarlist=[]
for i in range(int(f/c)+1):
  for j in range(int(f/d)+1):
    if c*i+d*j <=f:
      sugarlist+=[c*i+d*j]
sugarlist=list(set(sugarlist))
#print(y)

density=0
ans1=101
ans=1
for i in range(len(waterlist)):
  for j in range(len(sugarlist)):
    if 0 < waterlist[i]+sugarlist[j] <= f and sugarlist[j]<=waterlist[i]/100*e:
      tmp=sugarlist[j]/(waterlist[i]+sugarlist[j])
      if density < tmp:
        density = tmp
        ans1=waterlist[i]+sugarlist[j]
        ans2=sugarlist[j]
        
print(ans1,ans2)

Submission status: Runtime Error

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

waterlist=[]
for i in range(int(f/100/a)+1):
  for j in range(int(f/100/b)+1):
    if 100*a*i+100*b*j <=f:
      waterlist+=[100*a*i+100*b*j]
waterlist=list(set(waterlist))
#print(x)

sugarlist=[]
for i in range(int(f/c)+1):
  for j in range(int(f/d)+1):
    if c*i+d*j <=f:
      sugarlist+=[c*i+d*j]
sugarlist=list(set(sugarlist))
#print(y)

density=0

for i in range(len(waterlist)):
  for j in range(len(sugarlist)):
    if 0 < waterlist[i]+sugarlist[j] <= f and sugarlist[j]<=waterlist[i]/100*e:
      tmp=sugarlist[j]/(waterlist[i]+sugarlist[j])
      if density < tmp:
        density = tmp
        ans1=waterlist[i]+sugarlist[j]
        ans2=sugarlist[j]
        
print(ans1,ans2)

Submission status: Runtime Error

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

den=0
ans2=0
for i in range(int(f/a)+1):
  for j in range(int(f/b)+1):
    water = 100*a*i+100*b*j
    maxsugar=int(water/100)*e
    if water + maxsugar <= f:
      for k in range(0,int(maxsugar/c)+1):
        for l in range(0,int(maxsugar/d)+1):
          sugar=c*k+d*l
          if 0 < water+sugar <= f and sugar <=maxsugar:
            if den < sugar/(water+sugar):
              den=sugar/(water+sugar)
              ans1=water+sugar
              ans2=sugar

print(ans1,ans2)

Submission status: Runtime Error

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

den=0
ans2=0
for i in range(30+1):
  for j in range(15+1):
    water = 100*a*i+100*b*j
    maxsugar=int(water/100)*e
    if water + maxsugar <= f:
      for k in range(0,maxsugar+1):
        for l in range(0,maxsugar+1):
          sugar=c*k+d*l
          if 0 < water+sugar <= f and sugar <=maxsugar:
            if den < sugar/(water+sugar):
              den=sugar/(water+sugar)
              ans1=water+sugar
              ans2=sugar

print(ans1,ans2)

Submission status: Runtime Error

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

den=0

for i in range(30+1):
  for j in range(15+1):
    water = 100*a*i+100*b*j
    maxsugar=int(water/100)*e
    if water + maxsugar <= f:
      for k in range(0,maxsugar+1):
        for l in range(0,maxsugar+1):
          sugar=c*k+d*l
          if 0 < water+sugar <= f and sugar <=maxsugar:
            if den < sugar/(water+sugar):
              den=sugar/(water+sugar)
              ans1=water+sugar
              ans2=sugar

print(ans1,ans2)

Submission status: Runtime Error

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

den=0

for i in range(30+1):
  for j in range(15+1):
    water = 100*a*i+100*b*j
    maxsugar=int(water/100)*e
    if water + maxsugar <= f:
      for k in range(0,int(maxsugar/c)+1):
        for l in range(0,int(maxsugar/d)+1):
          sugar=c*k+d*l
          if 0 < water+sugar <= f and sugar <=maxsugar:
            if den < sugar/(water+sugar):
              den=sugar/(water+sugar)
              ans1=water+sugar
              ans2=sugar

print(ans1,ans2)

Submission status: Runtime Error

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

den=0

for i in range(30+1):
  for j in range(15+1):
    water = 100*a*i+100*b*j
    maxsugar=int(water/100)*e
    if water + maxsugar <= f:
#      print(water,maxsugar)
      for k in range(0,int(maxsugar/c)+1):
        for l in range(0,int(maxsugar/d)+1):
          sugar=c*k+d*l
#          print(water,sugar)
          if 0 < water+sugar <= f and sugar <=maxsugar:
            if den < sugar/(water+sugar):
              den=sugar/(water+sugar)
              ans1=water+sugar
              ans2=sugar

print(ans1,ans2)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = [int(i) for i in input().split()]
#print(a,b,c,d,e,f)

nod=0
for i in range(30+1):
  for j in range(30-i+1):
    for k in range(100+1):
      for l in range(100-k+1):
        if 0 < 100*(a*i+b*j)+c*k+d*l <= f and c*k+d*l <= e*(i+j):
          tmp=(c*k+d*l)/(100*(a*i+b*j)+c*k+d*l)
          if nod < tmp:
            nod=tmp
            ans1=100*(a*i+b*j)+c*k+d*l
            ans2=c*k+d*l
                        
print(ans1,ans2)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = [int(i) for i in input().split()]
print(a,b,c,d,e,f)

nod=0
for i in range(30+1):
  for j in range(30-i+1):
    for k in range(100+1):
      for l in range(100-k+1):
        if 0 < 100*(a*i+b*j)+c*k+d*l <= f and c*k+d*l <= e*(i+j):
          tmp=(c*k+d*l)/(100*(a*i+b*j)+c*k+d*l)
          if nod < tmp:
            nod=tmp
            ans1=100*(a*i+b*j)+c*k+d*l
            ans2=c*k+d*l
                        
print(ans1,ans2)

Submission status: Runtime Error

Solution code:
#encoding:utf-8

import math
import sympy

N,P = map(int,input().split())

facters = sympy.factorint(P)

ans = 1
for key in facters.keys():
    if facters[key]/N >= 1:
        ans *= key**(facters[key]//N)
print(int(ans))

Submission status: Runtime Error

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

n = f//(100*a)
m = f//(100*b)
p = f//c
q = f//d

mx = 0
for k in range(p+1):
    for l in range(q+1):
        for i in range(n+1):
            for j in range(m+1):
                if i == 0 and j == 0:
                    continue
                s = 100*a*i+100*b*j
                t = c*k+d*l
                u = 100*t/s
                if s + t> f:
                    continue
                if u > e:
                    continue
                if mx < u:
                    mx = u
                    ans1, ans2 = s+t, t
                    if mx == e:
                        print(ans1, ans2)
                        exit()
print(ans1, ans2)

Submission status: Runtime Error

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

max_rate = -1
ans = None
for i in range(30 // A + 1):
    for j in range(30 // B + 1):
        water = A * i + B * j
        # escape
        if water == 0: continue
        elif 100 * water > F: break
        elif (F - 100 * water) / water < max_rate: continue
        # search (safer version)
        salt_upper = int(E * water)
        max_rate_tmp = 0
        ans_tmp = None
        for k in list(range(salt_upper // C + 1))[::-1]:
            for l in list(range(salt_upper // D + 1))[::-1]:
                salt = k * C + D * l
                # escape
                if salt / water > E: continue
                elif salt + 100 * water > F: continue
                # judge (only for max l)
                if salt / water > max_rate_tmp:
                    ans_tmp = (i, j, k, l)
                    max_rate_tmp = salt / water
                break
        # end loop
        if ans_tmp == None: continue
        if max_rate_tmp > max_rate:
            ans = ans_tmp
            max_rate = max_rate_tmp
        if max_rate == E: break
    if max_rate == E: break

salt = C * ans[2] + D * ans[3]
water = 100 * (A * ans[0] + B * ans[1])
    
print(salt + water, salt)

Submission status: Runtime Error

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

max_rate = -1
ans = None
for i in range(30 // A + 1):
    for j in range(30 // B + 1):
        water = A * i + B * j
        # escape
        if water == 0: continue
        elif 100 * water > F: break
        elif (F - 100 * water) / water < max_rate: continue
        # search
        salt_upper = int(E * water)
        max_rate_tmp = 0
        ans_tmp = None
        for l in list(range(salt_upper // D + 1))[::-1]:
            salt = ((salt_upper - l * D) // C) * C + l * D
            rate_tmp = salt / water
            if rate_tmp == E:
                if 100 * water + salt > F: continue
                ans_tmp = (i, j, ((salt_upper - l * D) // C), l)
                break
            elif rate_tmp > max_rate_tmp:
                if 100 * water + salt > F: continue
                ans_tmp = (i, j, ((salt_upper - l * D) // C), l)
                max_rate_tmp = rate_tmp
                continue
            else:
                continue
        # end loop
        if ans_tmp == None: continue
        if max_rate_tmp > max_rate:
            ans = ans_tmp
            max_rate = max_rate_tmp
        if max_rate == E: break
    if max_rate == E: break

salt = C * ans[2] + D * ans[3]
water = 100 * (A * ans[0] + B * ans[1])
    
print(salt + water, salt)

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans = []
water = []
for i in range(31):
    for j in range(31):
        tmp = 100*i*A + 100*j*B
        if tmp <= F:
            water.append(tmp)
water = list(set(water))
water.remove(0)

sugar = []
for i in range(101):
    for j in range(101):
        tmp = i*C + j*D
        if tmp <= F:
            sugar.append(tmp)
sugar = list(set(sugar))
sugar.remove(0)

            
for miz in water:
    for sato in sugar:
        if miz + sato <= F and (100 * sato) // (miz + sato) <= (100 * E) // (100 + E):
            ans.append([miz, sato, (miz * sato) // (miz + sato)])
            
ans.sort(key=lambda x:x[2], reverse = True)
print(ans[0][0]+ans[0][1], ans[0][1])

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans = []
water = []
for i in range(31):
    for j in range(31):
        tmp = 100*i*A + 100*j*B
        if tmp <= F:
            water.append(tmp)
water = list(set(water))
water.remove(0)

sugar = []
for i in range(101):
    for j in range(101):
        tmp = i*C + j*D
        if tmp <= F:
            sugar.append(tmp)
sugar = list(set(sugar))
sugar.remove(0)

            
for miz in water:
    for sato in sugar:
        if miz + sato <= F and (100 * sato) / (miz + sato) <= (100 * E) / (100 + E):
            ans.append([miz, sato, (miz * sato) / (miz + sato)])
            
ans.sort(key=lambda x:x[2], reverse = True)
print(ans[0][0]+ans[0][1], ans[0][1])

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans = []
water = []
for i in range(31):
    for j in range(31):
        tmp = 100*i*A + 100*j*B
        if tmp <= F:
            water.append(tmp)
water = list(set(water))
water.remove(0)

sugar = []
for i in range(101):
    for j in range(101):
        tmp = i*C + j*D
        if tmp <= F:
            sugar.append(tmp)
sugar = list(set(sugar))
sugar.remove(0)

            
for miz in water:
    for sato in sugar:
        if miz + sato <= F and (miz * sato) / (miz + sato) <= (100 * E) / (100 + E):
            ans.append([miz, sato, (miz * sato) / (miz + sato)])
            
ans.sort(key=lambda x:x[2], reverse = True)
print(ans[0][0]+ans[0][1], ans[0][1])

Submission status: Runtime Error

Solution code:
a*=100
b*=100
res=chk=0
ans=[]
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                w=i*a+j*b
                s=k*c+l*d
                if w+s==0: pass
                elif w+s<f and (100*s)//(w+s)<=e*(w//100):
                    res=max(res,(100*s)//(w+s))
                    ans=[w+s,s]
print(*ans)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
ans=chk=0
for i in range(31)
    for j in range(31):
        for k in range(31):
            for l in range(31):
                w=i*a+j*b
                s=k*c+l*d
                if w+s<f and (100*s)//(w+s)<=e*(w//100): ans=max(ans,(100*s)//(w+s)
print(ans)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
x = []
y = []
t = 100 * e / (100 + e)
for i in range(f // (100 * a) + 1):
    bb = f - 100 * a * i
    for j in range(bb // (100 * b) + 1):
        if 100 * (a * i + b * j) in x:
            continue
        else:
            x.append(100 * (a * i + b * j))
for i in range(f // c + 1):
    dd = f - c * i
    for j in range(dd // d + 1):
        if c * i + d * j in y:
            continue
        else:
            y.append(c * i + d * j)
y.sort()
rr = 0
ans = []
for i, xi in enumerate(x):
    for j, yi in enumerate(y):
        if xi + yi == 0:
            continue
        r = 100 * yi / (xi + yi)
        if r > t:
            break
        elif xi + yi <= f and rr < r:
            ans = [xi + yi, yi]
            rr = r
print(ans[0], ans[1])

Submission status: Runtime Error

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

n = [[0, 0] for _ in range(f + 1)]
n[a][0] = a
for i in range(f + 1 - a):
    if n[i][0] != 0:
        n[i + a][0] = n[i][0] + a
n[b][0] = b
for i in range(f + 1 - b):
    if n[i][0] != 0:
        n[i + b][0] = n[i][0] + b
for i in range(f + 1 - c):
    if n[i][0] == 0:
        continue
    tmpt = n[i][0] / 100
    if (c + n[i][1]) / tmpt <= e :
        if n[i + c][1] == 0 and n[i + c][1] / (i + c) < (n[i][1] + c) / (i + c):
            n[i + c][0] = n[i][0]
            n[i + c][1] = n[i][1] + c
for i in range(f + 1 - d):
    if n[i][0] == 0:
        continue
    tmpt = n[i][0] / 100
    if (d + n[i][1]) / tmpt <= e:
        if n[i + d][1] == 0 and n[i + d][1] / (i + d) < (n[i][1] + d) / (i + d):
            n[i + d][0] = n[i][0]
            n[i + d][1] = n[i][1] + d
maxp = [0, 100, 0]
for i in range(len(n)):
    if(n[i][1] != 0 and maxp[0] < n[i][1] / i):
        maxp = [n[i][1] / i] + n[i]
print(str(maxp[1] + maxp[2]) + ' ' + str(maxp[2]))

Submission status: Runtime Error

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

n = [[0, 0] for _ in range(f + 1)]
n[a][0] = a
for i in range(f + 1 - a):
    if n[i][0] != 0:
        n[i + a][0] = n[i][0] + a
n[b][0] = b
for i in range(f + 1 - b):
    if n[i][0] != 0:
        n[i + b][0] = n[i][0] + b
for i in range(f + 1 - c):
    if n[i][0] == 0:
        continue
    tmpt = n[i][0] / 100
    if (c + n[i][1]) / tmpt <= e and n[i + c][1] / (i + c) < (n[i][1] + c) / (i + c):
        n[i + c][0] = n[i][0]
        n[i + c][1] = n[i][1] + c
for i in range(f + 1 - d):
    if n[i][0] == 0:
        continue
    tmpt = n[i][0] / 100
    if (d + n[i][1]) / tmpt <= e and n[i + d][1] / (i + d) < (n[i][1] + d) / (i + d):
        n[i + d][0] = n[i][0]
        n[i + d][1] = n[i][1] + d
maxp = [0, 100, 0]
for i in range(len(n)):
    if(n[i][1] != 0 and maxp[0] < n[i][1] / i):
        maxp = [n[i][1] / i] + n[i]
print(str(maxp[1] + maxp[2]) + ' ' + str(maxp[2]))