Problem:
Discounts of Buckwheat Aizu is famous for its buckwheat. There are many people who make buckwheat noodles by themselves. One day, you went shopping to buy buckwheat flour. You can visit three shops, A, B and C. The amount in a bag and its unit price for each shop is determined by the follows table. Note that it is discounted when you buy buckwheat flour in several bags.   Shop A Shop B Shop C  Amount in a bag 200g 300g 500g  Unit price for a bag (nominal cost) 380 yen 550 yen 850 yen  Discounted units per 5 bags per 4 bags per 3 bags  Discount rate reduced by 20 % reduced by 15 % reduced by 12 %   For example, when you buy 12 bags of flour at shop A, the price is reduced by 20 % for 10 bags, but not for other 2 bags. So, the total amount shall be (380 × 10) × 0.8 + 380 × 2 = 3,800 yen. Write a program which reads the amount of flour, and prints the lowest cost to buy them. Note that you should buy the flour of exactly the same amount as the given input. Input The input consists of multiple datasets. For each dataset, an integer a (500 ≤ a ≤ 5000, a is divisible by 100) which represents the amount of flour is given in a line. The input ends with a line including a zero. Your program should not process for the terminal symbol. The number of datasets does not exceed 50. Output For each dataset, print an integer which represents the lowest cost. Sample Input 500
2200
0 Output for the Sample Input 850
3390

Solution (Python):
cost = {15:2244,12:1870,10:1520,5:850,3:550,2:380}

mincost =  [10000]*51

for j in cost:
    mincost[j] = cost[j]
for i in range(4,51):
    for j in cost:
        if mincost[i-j] < 10000 and mincost[i] > mincost[i-j] + cost[j]:
            mincost[i] = mincost[i-j] + cost[j]

while True:
    n = int(raw_input())
    if n == 0:
        break 
    print mincost[n/100]

Solution (Python):
def f(w1):
  x=[]
  a1=w1/500
  for i1 in range(a1+1):
    w2=w1-i1*500
    a2=w2/300
    for i2 in range(a2+1):
      w3=w2-i2*300
      if w3%200==0: x.append([w3/200,i2,i1])
  return x

def g(x):
  m=1e9
  A=[380,550,850]
  B=[.2,.15,.12]
  C=[5,4,3]
  for e in x:
    a=0
    for i in [0,1,2]:
      b=e[i]/C[i]*C[i]
      a+=A[i]*(e[i]-b*B[i])
    m=min(m,a)
  return m

while 1:
  w=input()
  if w==0: break
  print int(g(f(w)))

Solution (Python):
def f(w1):
  m=1e9
  for i1 in range(w1/500+1):
    w2=w1-i1*500
    for i2 in range(w2/300+1):
      w3=w2-i2*300
      if w3%200==0: m=min(m,g([w3/200,i2,i1]))
  return m

def g(x):
  A=[380,550,850]
  B=[.2,.15,.12]
  C=[5,4,3]
  return sum([A[i]*(x[i]-x[i]/C[i]*C[i]*B[i]) for i in [0,1,2]])

while 1:
  w=input()
  if w==0: break
  print int(f(w))

Solution (Python):
def f(w1):
  m=1e9
  for i1 in range(w1/5+1):
    w2=w1-i1*5
    for i2 in range(w2/3+1):
      w3=w2-i2*3
      if w3%2==0: m=min(m,g([w3/2,i2,i1]))
  return m

def g(x):
  A=[380,550,850]
  B=[.2,.15,.12]
  C=[5,4,3]
  return sum([A[i]*(x[i]-x[i]/C[i]*C[i]*B[i]) for i in [0,1,2]])

while 1:
  w=input()
  if w==0: break
  print int(f(w/100))

Solution (Python):
P=[99999,99999,380,550,760,850,1100,1230,1400,1610,1520,1950,1870,2070,2250,2244]
for i in range(16,51):
    P.append(min(P[i-2]+380,P[i-3]+550,P[i-5]+850,P[i-10]+1520,P[i-12]+1870,P[i-15]+2244))

while(1):
    q=int(raw_input())
    if q==0:
        break
    else:
        print P[q/100]

Solution (Python):
while True:
    N = int(input())
    if not N: break
    ans = float('inf')
    for c200 in range(N//200+1):
        for c300 in range(N//300+1):
            for c500 in range(N//500+1):
                if 200 * c200 + c300 * 300 + c500 * 500 == N:
                    ans = min(ans, 1520*(c200//5)+380*(c200%5)+1870*(c300//4)+550*(c300%4)+2244*(c500//3)+850*(c500%3))
    print(ans)

Solution (Python):
while True:
  n = int(input())
  if n == 0:
    break
  c = 10000
  for i in range(n//500+1):
    n1 = n - 500*i
    c1 = (850*3*0.88)*(i//3)+850*(i%3) 
    for j in range(n1//300+1):
      n2 = n1 - 300*j
      if n2 % 200 == 0:
        k = n2 // 200
        c2 = c1 + (550*4*0.85)*(j//4)+550*(j%4)+(380*5*0.8)*(k//5)+380*(k%5)
        if c2 <= c:
          c = c2
  print(int(c))

Solution (Python):
while True:
	n = int(input())
	if n == 0:
		break
	cheapest = float('inf')
	for bagsA in range(n // 200 + 1):
		for bagsB in range(n // 300 + 1):
			for bagsC in range(n // 500 + 1):
				if 200 * bagsA + 300 * bagsB + 500 * bagsC == n:
					price = 1520 * (bagsA // 5) + 380 * (bagsA % 5) + 1870 * (bagsB // 4) + 550 * (bagsB % 4) + 2244 * (bagsC // 3) + 850 * (bagsC % 3)
					cheapest = min(cheapest, price)
	print(cheapest)

Solution (Python):
a=[2,3,5,10,12,15]
b=[380,550,850,1520,1870,2244]
while 1:
    n=int(input())
    if n==0:break
    n//=100
    dp=[0]+[1<<29]*n
    for i in range(5,-1,-1):
        for j in range(n+1):
            if j+a[i]<=n and dp[j]!=1<<29:dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i])
    print(dp[n])

Solution (Python):
a=[(2,380),(3,550),(5,850),(10,1520),(12,1870),(15,2244)]
dp=[1<<20]*51
for i,j in a:
    dp[i]=j
    for k in range(51-i):
        if dp[k]!=1<<20 and dp[k+i]>dp[k]+j:
            dp[k+i]=dp[k]+j
while 1:
    n=int(input())
    if n==0:break
    print(dp[n//100])

Solution (Python):
from itertools import combinations_with_replacement
while True:
    price = int(input())
    if price == 0: break
    candidates = []
    for i in range(1, 25):
        tmp = list(combinations_with_replacement([200, 300, 500], i))
        for t in tmp:
            if sum(t) == price:
                candidates.append(t)
    ans = []
    for candidate in candidates:
        i=j=k=0
        for c in candidate:
            if c == 200:
                i += 1
            elif c == 300:
                j += 1
            else:
                k += 1
        m200, m300, m500 = divmod(i, 5)[1], divmod(j, 4)[1], divmod(k, 3)[1]
        ans.append(380*(i-m200)*0.8+380*m200 + 550*(j-m300)*0.85+550*m300 + 850*(k-m500)*0.88+850*m500)
    print(int(min(ans)))

Solution (Python):


import sys
import os

for s in sys.stdin:
    n = int(s)
    if n == 0:
        break

    costs = []
    for a in range(0, 26):
        for b in range(0, 17):
            for c in range(0, 11):
                
                if a * 200 + b * 300 + c * 500 == n:
                    cost = 0
                    a_bulk_num = a // 5
                    a_price_down_num = a_bulk_num * 5
                    a_normal_price_num = a - a_price_down_num
                    cost += 380 * 0.8 * a_price_down_num + 380 * a_normal_price_num

                    b_bulk_num = b // 4
                    b_price_down_num = b_bulk_num * 4
                    b_normal_price_num = b - b_price_down_num
                    cost += 550 * 0.85 * b_price_down_num + 550 * b_normal_price_num

                    c_bulk_num = c // 3
                    c_price_down_num = c_bulk_num * 3
                    c_normal_price_num = c - c_price_down_num
                    cost += 850 * 0.88 * c_price_down_num + 850 * c_normal_price_num

                    costs.append(cost)

    print(int(min(costs)))

Solution (Python):
Soba = [[2,380],[3,550],[5,850],[10,1520],[12,1870],[15,2244]] 
while True:
    g = int(input())
    if g == 0:
        break
    g_g = int(g / 100)
    DP = [[10000 for j in range(g_g + 1)] for i in range(7)]
    for i in range(7):
        DP[i][0] = 0
    for i in range(7):
        for j in range(g_g + 1):
            if j - Soba[i - 1][0] + 1 >= 0: 
                DP[i][j] = min(DP[i-1][j],DP[i][j - Soba[i - 1][0]] + Soba[i - 1][1])
            else:
                DP[i][j] = DP[i - 1][j]
    print(DP[6][g_g])

Solution (Python):

"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0106&lang=jp
"""
import sys


def solve(amount):
    """
    :param amount: ?????\???????????°?????????
    :return: ?????????
    """
    best_price = (amount + 199) // 200 * 380
    for a in range(amount // 200 + 1):
        for b in range(amount // 300 + 1):
            for c in range(amount // 500 + 1):
                for a1 in range(amount // 1000 + 1):
                    for b1 in range(amount // 1200 + 1):
                        for c1 in range(amount // 1500 + 1):
                            if a*200 + b*300 + c*500 + a1*1000 + b1*1200 + c1*1500 == amount:
                                price = a*380 + b*550 + c*850 + a1*1520 + b1*1870 + c1*2244
                                if price < best_price:
                                    best_price = price
    return best_price




def main(args):
    while True:
        amount = int(input())
        if amount == 0:
            break
        result = solve(amount)
        print(result)



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

Solution (Python):

"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0106&lang=jp
"""
import sys


def solve(amount):
    """
    :param amount: ?????\???????????°?????????
    :return: ?????????
    """
    best_price = (amount + 199) // 200 * 380
    for a in range(amount // 200 + 1):
        for b in range(amount // 300 + 1):
            for c in range(amount // 500 + 1):
                for a1 in range(amount // 1000 + 1):
                    for b1 in range(amount // 1200 + 1):
                        for c1 in range(amount // 1500 + 1):
                            if a*200 + b*300 + c*500 + a1*1000 + b1*1200 + c1*1500 == amount:
                                price = a*380 + b*550 + c*850 + a1*1520 + b1*1870 + c1*2244
                                if price < best_price:
                                    best_price = price
    return best_price


def solve2(amount):
    """
    ???????¨???????????????¨?????????????????§???
    """
    packages = [(0, 0), (2, 380), (3, 550), (5, 850), (10, 1520), (12, 1870), (15, 2244)] 
    
    
    cart = [[99999999] * (amount//100 + 1) for _ in range(len(packages))]
    for i in range(len(packages)):
        cart[i][0] = 0          

    for i in range(1, len(packages)):
        for j in range(1, len(cart[0])):
            w = packages[i][0]  
            p = packages[i][1]  
            if j < w:
                cart[i][j] = cart[i-1][j]
            else:
                
                cart[i][j] = min(cart[i-1][j], cart[i-1][max(0, j-w)]+p, cart[i][max(0, j-w)]+p)
    return cart[-1][-1]


def main(args):
    while True:
        amount = int(input())
        if amount == 0:
            break
        
        
        result = solve2(amount)
        print(result)


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

Solution (Python):
h={15:2244,12:1870,10:1520,5:850,3:550,2:380}
m={0:0}

for i in range(50):
  if i in m:
    for k,v in h.items():
      m[i+k] = min(m.get(i+k,1e9),m[i]+v)

while True:
  n = input()
  if n == 0 : break
  print(m[n/100])

Solution (Python):
import sys


def price(pack,unit_price,units,off):
    return pack//units*units*unit_price*(1.-off) + pack%units*unit_price


def solve():
    while True:
        w = int(sys.stdin.readline())
        if w == 0 :return
        min = max([380*25,550*17,850*10])
        for a in range(0,w//200+1):
            need = w - a*200 
            for b in range(0,need//300+1):
                if((need-b*300)%500!=0):continue
                c = (need-b*300)//500
                p = price(a,380,5,0.2)+price(b,550,4,0.15)+price(c,850,3,0.12)
                if p < min:
                    min = p
        print("{:.0f}".format(min))
solve()

Solution (Python):
while True:
 N = int(input())
 if N==0: break
 ans = float('inf')
 for c200 in range(N//200+1):
  for c300 in range(N//300+1):
   for c500 in range(N//500+1):
    if 200 * c200 + c300 * 300 + c500 * 500 == N:
     ans = min(ans, 1520*(c200//5)+380*(c200%5)+1870*(c300//4)+550*(c300%4)+2244*(c500//3)+850*(c500%3))
 print(ans)

Solution (Python):
a=[1e4]*51
for i,j in[(2,380),(3,550),(5,850),(10,1520),(12,1870),(15,2244)]:
 a[i]=j
 for k in range(51-i):
  if a[k+i]>a[k]+j:a[k+i]=a[k]+j
for n in iter(input,'0'):print(a[int(n)//100])

Solution (Python):
a=[1e4]*51
for i,j in[(2,380),(3,550),(5,850),(10,1520),(12,1870),(15,2244)]:
 a[i]=j
 for k in range(51-i):a[k+i]=min(a[k]+j,a[k+i])
for n in iter(input,'0'):print(a[int(n)//100])

Solution (Python):
a=[1e4]*51
for i,j in[(2,380),(3,550),(5,850),(10,1520),(12,1870),(15,2244)]:
 a[i]=j
 for k in range(51-i):a[k+i]=min(a[k+i],a[k]+j)
for n in iter(input,'0'):print(a[int(n)//100])

Solution (Python):
def calc(A, B, C):
    da = A // 5
    na = A % 5
    db = B // 4
    nb = B % 4
    dc = C // 3
    nc = C % 3
    return da*1520 + na*380 + db*1870 + nb*550 + dc*2244 + nc*850

def f(a, b, c, g):
    if g == 0:
        return calc(a, b, c)
    if g < 0:
        return 10000000

    return min(f(a+1, b, c, g-2), f(a, b+1, c, g-3), f(a, b, c+1, g-5))

ans = [0,0,0,0,0,850,1100,1230,1400,1610,1520,\
       1950,1870,2070,2250,2244,2620,2624,2794,3004,3040,\
       3344,3390,3590,3740,3764,4120,4114,4314,4494,4488,\
       4864,4868,5038,5248,5284,5588,5634,5834,5984,6008,\
       6364,6358,6558,6738,6732,7108,7112,7282,7492,7528]

while True:
    N = int(input())
    if N == 0:
        break
    print(ans[N//100])

Solution (Python):
INF = 10 ** 20

def solve(n):
  ans = INF
  for i in range(n // 500 + 1):
    for j in range((n - 500 * i) // 300 + 1):
      if not (n - 500 * i - 300 * j) % 200:
        a = (n - 500 * i - 300 * j) // 200
        va = a // 5 * 1900 * 0.8  + a % 5 * 380
        vb = j // 4 * 2200 * 0.85 + j % 4 * 550
        vc = i // 3 * 2550 * 0.88 + i % 3 * 850
        ans = min(ans, va + vb + vc)
  print(int(ans))

while True:
  n = int(input())
  if not n:
    break
  solve(n)

Solution (Python):



a = [ 2, 3, 5 ]
s = [ 380, 550, 850 ]
c = [ 10, 12, 15 ]
f = [ 1520, 1870, 2244 ]
tbl = [0]*60

def rec(i, v, cost):
	if i == 3:
		if (v <= 50 and tbl[v] == 0) or tbl[v] > cost: tbl[v] = cost
		return
	for j in range(0, 51-v, a[i]):
		cc = j // c[i] * f[i] + (j % c[i]) // a[i] * s[i]
		rec(i+1, v+j, cost+cc)

rec(0, 0, 0)
while True:
	n = int(input())
	if n == 0: break
	print(tbl[n//100])

Solution (Python):
def ceil(n, m):
  return n / m + 2 if n % m != 0 else n / m + 1

def gram(l):
  return 200 * l[0] + 300 * l[1] + 500 * l[2]

def price(l):
  def c(n, m, p, r):
    d = (n / m) * m
    return ((n - d) + d * r) * p

  return int(c(l[0], 5, 380, 0.80) + c(l[1], 4, 550, 0.85) + c(l[2], 3, 850, 0.88))

t = []
for amount in range(500, 5500, 100):
  for a in range(ceil(amount, 200)):
    for b in range(ceil(amount, 300)):
      for c in range(ceil(amount, 500)):
        if gram([a, b, c]) == amount:
          t.append([gram([a, b, c]), [a, b, c]])

while True:
  data = input()
  if data == 0:
    break
  s = []
  for x in t:
    if x[0] == data:
      s.append(price(x[1]))
  print sorted(s)[0]

Solution (Python):
def price(num_unit, shop):
    A, B, C = 0, 1, 2
    
    if shop == A:
        num_discount = (num_unit / 5) * 5
        return 380 * num_discount * 0.8 + 380 * (num_unit % 5)
    elif shop == B:
        num_discount = (num_unit / 4) * 4
        return 550 * num_discount * 0.85 + 550 * (num_unit % 4)
    else:
        num_discount = (num_unit / 3) * 3
        return 850 * num_discount * 0.88 + 850 * (num_unit % 3)

while True:
    quantity = int(raw_input())
    if quantity == 0: break

    comb = []
    for a in range(quantity / 200 + 1):
        for b in range(quantity / 200 + 1):
            for c in range(quantity / 200 + 1):
                if a * 200 + b * 300 + c * 500 == quantity:
                    comb.append([a, b, c])

    prices = []
    for c in comb:
        prices.append(price(c[0], 0) + price(c[1], 1) + price(c[2], 2))

    print int(min(prices))

Solution (Python):
w=[200,300,500,1000,1200,1500]
p=[380,550,850,1520,1870,2244]
dp=[2<<20]*5001
dp[0]=0
for i in xrange(6):
    for j in xrange(0,5000-w[i]+1,100):
        dp[j+w[i]] = min(dp[j+w[i]] , dp[j]+p[i])
while True:
    n=input()
    if n==0:
        break
    print dp[n]

Solution (Python):
while 1:
    w = int(raw_input())
    if w == 0: break
    minp = 9500
    for c in range(11):
        for b in range(17):
            for a in range(26):
                t = 200 * a + 300 * b + 500 * c
                if t > w: break
                if t == w:
                    p = int(380 * (a - a % 5) * 0.8 + 380 * (a % 5)
                            + 550 * (b - b % 4) * 0.85 + 550 * (b % 4)
                            + 850 * (c - c % 3) * 0.88 + 850 * (c % 3))
                    minp = min(minp, p)
    print minp

Solution (Python):

import sys


class Item:
    def __init__(self, amount, price):
        self.amount = amount
        self.price = price


items = [ Item(200, 380),                   
          Item(300, 550),                   
          Item(500, 850),                   
          Item(200 * 5, 380 * 5 * 0.8),     
          Item(300 * 4, 550 * 4 * 0.85),    
          Item(500 * 3, 850 * 3 * 0.88) ]   


dp = [sys.maxint] * 5001
dp[0] = 0
for item in items:
    for i in xrange(0, 5001):
        if i + item.amount <= 5000:
            dp[i + item.amount] = min(dp[i + item.amount], dp[i] + item.price)

while True:
    amount = int(sys.stdin.readline())
    if amount == 0:
        exit()
    print int(dp[amount])

Solution (Python):

from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    price_table = (
        0, 0, 380, 550, 760, 850, 1100, 1230, 1400, 1610, 1520, 1950,
        1870, 2070, 2250, 2244, 2620, 2624, 2794, 3004, 3040, 3344,
        3390, 3590, 3740, 3764, 4120, 4114, 4314, 4494, 4488, 4864,
        4868, 5038, 5248, 5284, 5588, 5634, 5834, 5984, 6008, 6364,
        6358, 6558, 6738, 6732, 7108, 7112, 7282, 7492, 7528
        )
    while 1:
        weight = int(readline())
        if not weight:
            exit()
        print(price_table[weight//100])


if __name__ == '__main__':
    main()

Solution (Python):
r = 51
wc = [[15,2244],[10,1520],[12,1870],[5,850],[3,550],[2,380]]
dp = [0]*r
for w,c in wc:
	dp[w] = c
	for i in range(r - w):
		if dp[i] > 0 and (dp[i + w] == 0 or dp[i + w] > dp[i] + c):
			dp[i + w] = dp[i] + c

while 1:
	n = input()
	if n == 0: break
	print dp[n/100]

Solution (Python):
r,x = 51,2**31
wc = [[15,2244],[10,1520],[12,1870],[5,850],[3,550],[2,380]]
dp = [x]*r
for w,c in wc:
	dp[w] = c
	for i in range(r - w):
		if dp[i] < x and dp[i + w] > dp[i] + c:
			dp[i + w] = dp[i] + c

while 1:
	n = input()
	if n == 0: break
	print dp[n/100]

Solution (Python):
""" 
A店：200g,380y,20%/5 → 1.9y/g
B店：300g,550y,15%/4 → 1.83y/g
C店：500g,850y,12%/3 → 1.7y/g
380*5 *0.8 = 1520   304/1つ
550*4 *0.85 = 1870  467.5/1つ
850*3 *0.88 = 2244  748/1つ
"""


P = [2,10, 3,12, 5,15]
Q = [380,1520, 550,1870, 850,2244]
MAX = 50
Range = [0] + [1000000]*MAX

for p,q in zip(P,Q):
    for i in range(MAX - p+1):
        Range[i+p] = min(Range[i+p],Range[i]+q)

while True:
    v = int(input())
    if v==0:
        break
    print(Range[v//100])

Solution (Python):
P = [2, 10, 3, 12, 5, 15]
Q = [380, 1520, 550, 1870, 850, 2244]
MAX = 50
Range = [0] + [1000000] * MAX

for p, q in zip(P, Q):
    for i in range(MAX - p + 1):
        Range[i + p] = min(Range[i + p],Range[i] + q)
while 1:
    v = int(input())
    if v == 0:
        break
    print(Range[v // 100])

Solution (Python):
P = [2, 10, 3, 12, 5, 15]
Q = [380, 1520, 550, 1870, 850, 2244]
L = 50
R = [0] + [1e9]*L
for p, q in zip(P, Q):
    for i in range(L-p+1):
        R[i+p] = min(R[i+p], R[i] + q)
while 1:
    v = int(input())
    if v == 0:
        break
    print(R[v//100])

Solution (Python):
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


while True:

    N = int(input()) 
    if N == 0:
        break

    ans = BIG_NUM

    lim_A = N//200
    lim_B = N//300
    lim_C = N//500

    for a in range(lim_A+1):
        for b in range(lim_B+1):
            if 200*a+300*b > N:
                break
            rest = N-(200*a+300*b)
            if rest%500 != 0:
                continue
            c = rest//500

            sum_A = 380*(a%5)+304*(a-(a%5))
            sum_B = 550*(b%4)+935*(b-(b%4))//2
            sum_C = 850*(c%3)+1496*(c-(c%3))//2

            ans = min(ans,sum_A+sum_B+sum_C)

    print("%d"%(ans))

Solution (Python):






import sys
import math


class mymath:
    
    pi = 3.14159265358979323846264338

    
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

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

    
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()


class output:
    
    def list(self, l):
        l = list(l)
        
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()






















def printA(A):
    N = len(A)
    for i, n in enumerate(A):
        print(n, end='')
        if i != N-1:
            print(' ', end='')
    print()










def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            
            
        except EOFError:
            break
    return N

while True:
    M = int(input())
    if M==0:
        break
    
    cost = 1145141919

    for x1 in range(M//200+1):
        M1 = M - 200 * x1
        for x2 in range(M1//300+1):
            M2 = M1 - 300 * x2
            for x3 in range(M2//500+1):
                M3 = M2 - 500 * x3
                if M3 == 0:
                    f = 380*(x1%5) + 304*5*(x1//5) + 550*(x2%4) + 467.5*4*(x2//4) + 850*(x3%3) + 748*3*(x3//3)
                    if cost > f:
                        cost = f
                        

    print(int(cost))

Solution (Python):
while 1:
    try:
        inp=int(input())
        if inp==0:break
        m_list=[]
        for i in range(4):
            for j in range(5):
                for k in range(6):
                    for l in range(3):
                        for m in range(4):
                            for n in range(5):
                                if i*1500+j*1200+k*1000+l*500+m*300+n*200==inp:
                                    m_list.append(i*2244+j*1870+k*1520+l*850+m*550+n*380)
        print(min(m_list))
    except:break

Solution (Python):
while True:
    g = int(input())//100
    if g == 0:
        break
    p = 100000
    for a in range(g//2 + 1):
        for b in range(g//3 + 1):
            for c in range(g//5 + 1):
                if a*2 + b*3 + c*5 == g:
                    p = min(p, 1520*(a//5) + 380*(a%5) + 1870*(b//4) + 550*(b%4) + 2244*(c//3) + 850*(c%3))
    print(p)

Solution (Python):
INF = 10**20
def solve(n):
    inf = INF
    for i in range((n//500) + 1):
        for j in range(((n - 500*i)//300) + 1):
            if ((n - 500*i - 300*j)%200 == 0):
                a = (n - 500*i - 300*j)//200
                va = (a//5)*380*5*0.8 + (a%5)*380
                vj = (j//4)*550*4*0.85 + (j%4)*550
                vi = (i//3)*850*3*0.88 + (i%3)*850
                inf = min(inf, va+vj+vi)
    print(int(inf))
            
while True:
    n = int(input())
    if (not n):
        break
    solve(n)

Solution (Python):
p1,p2,p3 = 380,550,850
q1,q2,q3 = 200,300,500
d1,d2,d3 = 5,4,3
r1,r2,r3 = 0.2,0.15,0.12
arr = []
for tot in range(500,5001,100):
    lst = 1000000000
    for i in range(0,int(tot/q1)+1):
        for j in range(0,int(tot/q2)+1):
            for k in range(0,int(tot/q3)+1):
                if i*q1+j*q2+k*q3 == tot:
                    tmp = i*p1+j*p2+k*p3 - int(i/d1)*d1*p1*r1 - int(j/d2)*d2*p2*r2 - int(k/d3)*d3*p3*r3
                    lst = min(tmp,lst)
    arr.append([tot,int(lst)])
dic = dict(arr)
while(True):
    n = int(input())
    if n == 0:
        break
    print(dic[n])