Go: package main

import "fmt"

func main() {
	maxGram := 5000
	// store := map[int]int{
	// 	1500: 2244, // 500 * 3
	// 	1200: 1870, // 300 * 4
	// 	1000: 1520, // 200 * 5
	// 	500:  850,
	// 	300:  550,
	// 	200:  380,
	// }

	for {
		var gram int
		fmt.Scanf("%d", &gram)

		if gram == 0 {
			return
		}

		var minPrice int

		// (x * 200) + (y * 300) + (z * 500) == gram
		for x := 0; (x * 200) <= maxGram; x++ {
			for y := 0; (y * 300) <= maxGram; y++ {
				for z := 0; (z * 500) <= maxGram; z++ {
					if (x*200)+(y*300)+(z*500) == gram {
						price := 0
						price += (z / 3) * 2244
						price += (z % 3) * 850
						price += (y / 4) * 1870
						price += (y % 4) * 550
						price += (x / 5) * 1520
						price += (x % 5) * 380

						if price < minPrice || minPrice == 0 {
							minPrice = price
						}
					}
				}
			}
		}

		fmt.Println(minPrice)
	}
}

// 1 袋あたりの量			200g	300g	500g
// 1 袋の単価(定価)		380円	550円	850円
// 割引が適用される単位		5袋毎	4袋毎	3袋毎
// 割引率							20%引き	15%引き	12%引き

C++: #include <iostream>
#define MAX_P 1000000
using namespace std;
int g;
int minx=0;
/*
void price(int a,int b,int c){
	if(a/5*1520+a%5*380+b/4*1870+b%4*550+c/3*2244+c%3*850<minx)
		minx=a/5*1520+a%5*380+b/4*1870+b%4*550+c/3*2244+c%3*850;
	return; 
}

void shop(int g,int a,int b,int c){
	if(g==0){
		price(a,b,c);
		return;
	}else if(g<0){
		return;
	}
	shop(g-200,a+1,b,c);
	shop(g-300,a,b+1,c);
	shop(g-500,a,b,c+1);
	return;
}

int main(){
	while(1){
		cin >> g;
		if(g==0)break;
		minx=MAX_P;	
		shop(g,0,0,0);
		cout << minx << endl;
	}
	return 0;
}
*/
int main(){
	while(1){
		cin >> g;
		if(g==0)break;
		minx=MAX_P;
		for(int i=0;i<=25;i++){
			for(int j=0;j<17;j++){
				if(i*200+j*300>g)continue;
				for(int k=0;k<=10;k++){
					if(i*200+j*300+k*500>g)continue;
					if(i*200+j*300+k*500==g){
						if(i/5*1520+i%5*380+j/4*1870+j%4*550+k/3*2244+k%3*850<minx)
							minx=i/5*1520+i%5*380+j/4*1870+j%4*550+k/3*2244+k%3*850;
					}
				}
			}
		}
		cout << minx << endl;
	}
}

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

int main() {
  int ng;
  cin >> ng;
  vector<int> resultCandidits;
  for(int c = (ng / 500); c >= 0; --c) {
    int leftc = ng - c * 500;
    for(int b = leftc / 300; b >= 0; --b) {
      int leftb = leftc - b * 300;
      if(leftb % 200 == 0 && leftb / 200 >= 0) {
        int a = leftb / 200;
        // cout << (c / 3 * 2244 + c % 3 * 850) + (b / 4 * 1870 + b % 4 * 550) + (a / 5 * 1520 + a % 5 * 380) << endl;
        resultCandidits.push_back((c / 3 * 2244 + c % 3 * 850) + (b / 4 * 1870 + b % 4 * 550) + (a / 5 * 1520 + a % 5 * 380));
        // cout << "c:" << c << ", b:" << b << ", a:" << a << endl;
      }
    }
  }
  cout << *(min_element(resultCandidits.begin(), resultCandidits.end())) << endl;

  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int a[] = {380, 550, 850, 0.8*380*5, 0.85*550*4, 0.88*850*3};
  int w[] = {200, 300, 500, 200*5, 300*4, 500*3};

  int dp[7][5001] = {1<<30};
  REP(i,7)
    REP(j,5001) {
    dp[i][j] = 9999;
    if (j==0) dp[i][j]=0;
  }
    
  REP(i,6) {
    for (int j=0; j<=5000; j+=100) {
      if (j<w[i])
        dp[i+1][j] = dp[i][j];
      else
        dp[i+1][j] = min(dp[i][j], dp[i+1][j-w[i]] + a[i]);
//      printf("%5d", dp[i+1][j]);
    }
    //  cout << endl;
    
  }
  
  int n;
  while (cin >> n, n) {
    cout << dp[6][n] << endl;
  }
  
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int dp[10][1000];
int w[3] = { 2, 3, 5 };
int v[3] = { 380, 550, 850 };
double r[3] = { 0.8, 0.85, 0.88 };
int d[3] = { 5, 4, 3 };

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	while(cin >> n, n) {
		n /= 100;
		fill((int*)begin(dp), (int*)end(dp), 1e9);
		dp[0][0] = 0;
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j <= n; j++) {
				if(dp[i][j] == 1e9) continue;
				for(int k = 0; j + w[i] * k <= n; k++) {
					int cost = v[i] * (k / d[i]) * d[i] * r[i] + v[i] * (k % d[i]);
					int nj = j + w[i] * k;
					dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + cost);
				}
			}
		}
		cout << dp[3][n] << endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int dp[5001];
bool able[5001];

void init(){
	vector<int> item;
	item.push_back(200);
	item.push_back(300);
	item.push_back(500);
	item.push_back(1000);
	item.push_back(1200);
	item.push_back(1500);
	vector<int> price;
	price.push_back(380);
	price.push_back(550);
	price.push_back(850);
	price.push_back( 1520 );
	price.push_back( 1870 );
	price.push_back( 2244 );
	rep(i,5001)dp[i]=(1<<20);
	able[0]=true;
	dp[0]=0;
	for(int k=0;k<item.size();k++){	
		for(int i=0;i+item[k]<=5000;i++){
			able[i+item[k]] = able[i+item[k]] | able[i];
			if(able[i+item[k]]){
				dp[i+item[k]] = min( dp[i+item[k]] , dp[i]+price[k] );
			}
		}
	}
	return;
}

int main(){
	init();
	int n;
	int mi;
	while(cin >> n && n){
		/*mi = 1<<21;
		for(int i=n;i<=5000;i++){
			mi = min(dp[i],mi);
		}*/	
		cout << dp[n] << endl;
	}
}

C++: #include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#define INF 100000
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int moneyA(int gram){
	int n=gram/200;
	int res=gram%200;
	if(res)return INF;
	int money=0;
	int sell=n/5;
	int normal=n%5;
	money=sell*5*380*0.8+normal*380;
	return money;
}

int moneyB(int gram){
	int n=gram/300;
	int res=gram%300;
	if(res)return INF;
	int money=0;
	int sell=n/4;
	int normal=n%4;
	money=sell*4*550*0.85+normal*550;
	return money;
}

int moneyC(int gram){
	int n=gram/500;
	int res=gram%500;
	if(res)return INF;
	int money=0;
	int sell=n/3;
	int normal=n%3;
	money=sell*3*850*0.88+normal*850;
	return money;
}

int money=INF;

void func(int gram,int count,int cost){
	if(count==0){
		for(int i=0;i<=gram;i+=100){
			if(moneyA(i)!=INF)func(gram-i,count+1,cost+moneyA(i));
			else func(gram,count+1,cost);
		}
	}else if(count==1){
		for(int i=0;i<=gram;i+=100){
			if(moneyB(i)!=INF)func(gram-i,count+1,cost+moneyB(i));
			else func(gram,count+1,cost);
		}
	}else if(count==2){
		for(int i=0;i<=gram;i+=100){
			if(moneyC(i)!=INF)func(gram-i,count+1,cost+moneyC(i));
			else func(gram,count+1,cost);
		}
	}else{
		if(gram!=0)return;
		else{
			money=min(money,cost);
			return;
		}
	}
	count++;
}


int main(){
	int want;
	while(cin>>want,want){
		money=INF;
		func(want,0,0);
		cout<<money<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int minP = 999999999;
void DFS(int w, int p, int a, int b, int c)
{
	if(w == 0)
	{
		if(minP > p)
		{
			minP = p;
		}
	}
	if(w - 200 >= 0)
	{
		if(a + 1 < 5)
		{
			DFS(w - 200, p + 380, a + 1, b, c);
		}
		else
		{
			DFS(w - 200, p, 0, b, c);
		}
	}
	if(w - 300 >= 0)
	{
		if(b + 1 < 4)
		{
			DFS(w - 300, p + 550, a, b + 1, c);
		}
		else
		{
			DFS(w - 300, p + 220, a, 0, c);
		}
	}
	if(w - 500 >= 0)
	{
		if(c + 1 < 3)
		{
			DFS(w - 500, p + 850, a, b, c + 1);
		}
		else
		{
			DFS(w - 500, p + 544, a, b, 0);
		}
	}
	return;
}

void solve()
{
	int w;
	while(cin >> w, w)
	{
		minP = 999999999;
		DFS(w, 0, 0, 0, 0);
		cout << minP << endl;
	}
}

int main()
{
	solve();
	return(0);
}