Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const qA, qB, qC = 200, 300, 500
const pA, pB, pC = 380, 550, 850
const dA, dB, dC = 5, 4, 3

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		q, _ := strconv.Atoi(stdin.Text())
		if q == 0 {
			break
		}

		// A 0袋から始める
		curPrice, newPrice := 0, 0
		// B
		for a := 0; a <= int(q/qA); a++ {
			for b := 0; b <= int((q-qA*a)/qB); b++ {
				// 残り
				rem := q - qA*a - qB*b
				if rem == 0 || ((rem > 0) && ((rem % qC) == 0)) {
					// ちょうど買える
					newPrice = amount(a, b, int(rem/qC))
					if curPrice == 0 || newPrice < curPrice {
						// println(a, b, int(rem/qC), newPrice)
						curPrice = newPrice
					}
				}
			}
		}
		fmt.Println(curPrice)
	}
}

func amount(a, b, c int) int {
	tA := int(float64(int(a/dA)*dA*pA)*0.8) + (a%dA)*pA
	tB := int(float64(int(b/dB)*dB*pB)*0.85) + (b%dB)*pB
	tC := int(float64(int(c/dC)*dC*pC)*0.88) + (c%dC)*pC
	// println("amount:", a, b, c, tA, tB, tC, tA+tB+tC)
	return tA + tB + tC
}

C++: #include <iostream>

using namespace std;

int f(int weight){

	int tw[] = {500,300,200},b[3],tp[] = {850,550,380},c[3],price = 0,tmp,d;

	double a[] = {0.88,0.85,0.80};

	for(int i = 0;i < 3;++i){

		d = (tw[i] * (i + 3));

		if((weight % d) == 0){

			return (int)((double)(weight / tw[i] * tp[i]) * a[i]);

		}

		tmp = weight;

		b[i] = tmp / (tw[i] * (i + 3)) * (i + 3);

		tmp -= (tw[i] * b[i]);

		price += (int)((double)(b[i] * tp[i]) * a[i]);

		for(int j = i + 1;j < 3;++j){

			b[j] = tmp / (tw[j] * (j + 3)) * (j + 3);

			tmp -= (tw[j] * b[j]);

			price += (int)((double)(b[j] * tp[j]) * a[j]);

			if(tmp < 0){

				price = 0;

				break;

			}

			else if(tmp == 0){

				return price;

			}

		}

		price = 0;

		if((weight % tw[i]) == 0){

			d = weight / d * (i + 3);

			c[0] = (weight - (tw[i] * d)) / tw[i];

			return (int)((double)(d * tp[i]) * a[i]) + (c[0]* tp[i]);

		}

	}

	for(int i = 0;i < 3;++i){

		tmp = weight;

		b[i] = tmp / (tw[i] * (i + 3)) * (i + 3);

		tmp -= (tw[i] * b[i]);

		price += (int)((double)(b[i] * tp[i]) * a[i]);

		for(int j = i + 1;j < 3;++j){

			b[j] = tmp / (tw[j] * (j + 3)) * (j + 3);

			tmp -= (tw[j] * b[j]);

			price += (int)((double)(b[j] * tp[j]) * a[j]);

			if(tmp < 0){

				price = 0;

				break;

			}

			else if(tmp == 0){

				return price;

			}

		}

		price = 0;

	}

	price = 0;

	for(int i = 0;i < 3;++i){

		b[i] = weight / tw[i];

		weight -= tw[i] * b[i];

		c[i] = b[i] / (i + 3) * (i + 3);

		b[i] -= c[i];

		price += (int)((double)(tp[i] * c[i]) * a[i]) + (tp[i] * b[i]);

	}

	return price;

}

int main(){

	int n;

	while(cin >> n && n){

		cout << f(n) << endl;

	}

	return 0;

}

C++: #include<stdio.h>

#define min(a, b) ((a) < (b)?(a):(b))

int ans[55], i, j, k, x;
int main(){
    for(i = 0;i <= 50;i++){
	ans[i] = 1 << 30;
    }
    for(i = 0;i <= 25;i++){
	for(j = 0;j <= 17;j++){
	    for(k = 0;k <= 10;k++){
		int p = i * 2 + j * 3 + k * 5;
		if(p > 50)continue;
		int price;
		price = (i / 5) * 4 * 380 + (i % 5) * 380;
		price += (j / 4) * 550 * 4 * 85 / 100 + (j % 4) * 550;
		price += (k / 3) * 3 * 850 * 88 / 100 + (k % 3) * 850;
		ans[p] = min(price, ans[p]);
	    }
	}
    }
    while(scanf("%d", &x), x){
	printf("%d\n", ans[x / 100]);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

int main()
{
    int weight[6] = {2,3,5,10,12,15};
    int price[6] = {380,550,850,1520,1870,2240};
    int dp[52];
    int a=0;
    for(int i=0;i<52;i++){
        if(i>weight[a])
            a++;
        dp[i] = price[a];
    }
    dp[0] = 0;

    for(int i=0;i<52;i++){
        for(int j=0;j<6;j++){
            if(i-weight[j] >= 0)
                dp[i] = min(dp[i],dp[i-weight[j]]+price[j]);
        }
    }
    int n;
    while(cin >> n){
        if(n==0)
            break;
        cout << dp[n/100] << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>

#define Kinds 6
#define DP 50
const int cost[Kinds]={380,550,850,380*5*0.8,550*4*0.85,850*3*0.88};
const int Volume[Kinds]={200,300,500,1000,1200,1500};

unsigned int dp[DP];

int main(){
	int n;
	
	memset(dp,10000000,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<DP;++i)
		for(int l=0;l<Kinds;++l)
			if(i-Volume[l]/100>=0)
				dp[i]=std::min(dp[i],dp[i-Volume[l]/100]+cost[l]);
	while( std::cin>>n, n )
		std::cout<<dp[n/100]<<std::endl;
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#define INF 1<<28
using namespace std;

int solve(int n){
  int res = INF;
  if(!n) return 0;
  if(n < 0) return INF;
  return res = min(res, min(solve(n-1000)+1520, min(solve(n-1200)+1870, min(solve(n-1500)+2244, min(solve(n-200)+380, min(solve(n-300)+550, solve(n-500)+850))))));
}

int main(){ 
  int n;
  while(cin >> n, n) cout << solve(n) << endl; 
}

C++: #include<bits/stdc++.h>
using namespace std;
struct shop{
  int gram,tanka,tekiyou,tanni;
};
int main(){
  int n;
  int nedan[10000]={};
  for(int i=0;i<10000;i++)
    nedan[i]=1000000000;
  struct shop a[3];
  a[0].gram=200;a[0].tanka=380;a[0].tekiyou=1520;a[0].tanni=1000;
  a[1].gram=300;a[1].tanka=550;a[1].tekiyou=1870;a[1].tanni=1200;
  a[2].gram=500;a[2].tanka=850;a[2].tekiyou=2244;a[2].tanni=1500;
  queue<pair<int,int> >nn;
  for(int i=0;i<3;i++){
    nn.push(make_pair(a[i].gram,a[i].tanka));nn.push(make_pair(a[i].tanni,a[i].tekiyou));
  }
  nedan[200]=380;nedan[300]=550;nedan[500]=850;nedan[1000]=1520;
  nedan[1200]=1870;nedan[1500]=2244;
  while(!nn.empty()){
    pair<int,int>now=nn.front();
    nn.pop();
    if(now.first>5000)
      continue;
    for(int i=0;i<3;i++){
      if(now.first+a[i].gram<=5000){
	if(nedan[now.first+a[i].gram]>nedan[now.first]+a[i].tanka){
	  nedan[now.first+a[i].gram]=nedan[now.first]+a[i].tanka;
	  nn.push(make_pair(now.first+a[i].gram,nedan[now.first+a[i].gram]));
	}
      }
      if(now.first+a[i].tanni<=5000){
	if(nedan[now.first+a[i].tanni]>nedan[now.first]+a[i].tekiyou){
	  nedan[now.first+a[i].tanni]=nedan[now.first]+a[i].tekiyou;
	  nn.push(make_pair(now.first+a[i].tanni,nedan[now.first+a[i].tanni]));
	}
      }
    }
  }
  while(cin>>n,n!=0)
    cout<<nedan[n]<<endl;
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int priceAtA(int n) {
    int bags = ceil(n / 200.);
    int lp = bags % 5;
    return 380 * lp + (380 * (bags - lp) * 0.8);
}

int priceAtB(int n) {
    int bags = ceil(n / 300.);
    int lp = bags % 4;
    return 550 * lp + ceil(550 * (bags - lp) * 0.85);
}

int priceAtC(int n) {
    int bags = ceil(n / 500.);
    int lp = bags % 3;
    return 850 * lp + (850 * (bags - lp) * 0.88);
}

void solve107(int n) {
    int price = 1e9;
    for (int i = 0; i <= n; i+=100) {
        for (int j = 0; i + j <= n; j+=100) {
            for (int k = 0; i + j + k <= n; k+=100) {
                if (i + j + k == n) {
                    price = min(price, priceAtA(i) + priceAtB(j) + priceAtC(k));
                }
            }
        }
    }
    cout << price << endl;
}

int main() {
    int n;
    while(cin >> n, n) {
        solve107(n);
    }
    return 0;
}