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>
#include <algorithm>
#include <cstdlib>
#include <climits>
using namespace std;

enum stats_detail {
  WEIGHT = 0,
  PRICE  = 1,
  UNIT   = 2,
  RATE   = 3
};

enum shop {
  A = 0,
  B = 1,
  C = 2
};

const static int shop_stats[ 3 ][ 4 ] = {
  { 200, 380, 5, 20 },
  { 300, 550, 4, 15 },
  { 500, 850, 3, 12 }
};

const static int W_MAX = 5000;
const static int W_UNIT = 100;
const static int OPT_ARRAY_SIZE = W_MAX / W_UNIT + 1;

int get_price( shop id, int num ) {
  
  int discount_num = num - num % shop_stats[ id ][ UNIT ];
  return (
      shop_stats[ id ][ PRICE ] *
      discount_num *
      ( 100 - shop_stats[ id ][ RATE ] ) / 100  +
      shop_stats[ id ][ PRICE ] * ( num - discount_num )
 );
 
  return 0;
}
int main() {
  int opt[ OPT_ARRAY_SIZE ];
  fill( opt, opt + OPT_ARRAY_SIZE, INT_MAX );
  for( int i = 0; i <= W_MAX / shop_stats[ A ][ WEIGHT ]; i++ ) {
    int apr = get_price( A, i );
    int aw  = i * shop_stats[ A ][ WEIGHT ];
    for( int j = 0; j <= W_MAX / shop_stats[ B ][ WEIGHT ]; j++ ) {
      int bpr = get_price( B, j );
      int bw  = j * shop_stats[ B ][ WEIGHT ];
      for( int k = 0; k <= W_MAX / shop_stats[ C ][ WEIGHT ]; k++ ) {
        int cpr = get_price( C, k );
        int cw  = k * shop_stats[ C ][ WEIGHT ];
        int sumw = aw + bw + cw;
        if( sumw > W_MAX ) { continue; }
        opt[ sumw / W_UNIT ] = min( opt[ sumw / W_UNIT ], apr + bpr + cpr );
      }
    }
  } 
  while( 1 ) {
    int w;
    cin >> w;
    if( !w ) { break; }
    cout << opt[ w / W_UNIT ] << endl;
  }
  return EXIT_SUCCESS;
}

C++: # define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main()
{
	int v;
	while (cin >> v&&v)
	{
		int ans = INT_MAX;
		for (int a = 0;a<=30; a++)
		{
			for (int b = 0;b<=30; b++)
			{
				for (int c = 0; c <= 30; c++)
				{
					if (a * 200 + b * 300 + c * 500 == v)
					{
						int temp = a * 380 + b * 550 + c * 850;
						temp -= (a / 5) * 5 * (380 * 0.2);
						temp -= (b / 4) * 4 * (550 * 0.15);
						temp -= (c / 3) * 3 * (850 * 0.12);
						ans = min(ans, temp);
					}
				}
			}
		}
		cout << ans << endl;
	}
}