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 <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dp[200];
signed main(void) {
  REP(i, 200) dp[i] = INF;
  REP(i, 30) REP(j, 20) REP(k, 15) {
    int tmp = i * 2 + j * 3 + k * 5,
        ret = i / 5 * 5 * 304 + i % 5 * 380 + j / 4 * 4 * 550 * 0.85 +
              j % 4 * 550 + k / 3 * 3 * 850 * 0.88 + k % 3 * 850;
    dp[tmp] = min(dp[tmp], ret);
  }

  int n;
  while(cin >> n) {
    cout << dp[n/100] << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define NUM 6
#define MAX 5000
struct Data{int weight,cost;};
int main()
{
  int n;
  int dp[MAX+1]={0};
  Data item[NUM]={
    {200,380},{300,550},{500,850},{1000,1520},{1200,1870},{1500,2244}
  };
  for(int j=0;j<=MAX;j++)dp[j]=INT_MAX>>2;
  dp[0]=0;
  for(int i=0;i<NUM;i++){
    for(int j=item[i].weight;j<=MAX;j++){
      dp[j] = min( dp[j], dp[j-item[i].weight] + item[i].cost );
    }
  }

  while(cin>>n,n){
    cout<<dp[n]<<endl;
  }
}

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

struct soba{
	double gram;
	double yen;
	soba(double g, double y){gram=g;yen=y;}
};

double n;
double min_y;
vector<soba> v;


void buy(double sum_g, double sum_y){
	int len = v.size();
	for(int i=0;i < len;i++){
		if(sum_g == n){
			min_y = min(min_y, sum_y);
			return;
		}else if(sum_g > n){
			break;
		}
		buy(sum_g+v[i].gram, sum_y+v[i].yen);
	}
	return;
}


int main(){
	int sum_g, sum_y;
	v.push_back(soba(200,380));
	v.push_back(soba(200*5, (380*5) * 0.8));
	v.push_back(soba(300,550));
	v.push_back(soba(300*4, (550*4) * 0.85));
	v.push_back(soba(500,850));
	v.push_back(soba(500*3, (850*3) * 0.88));
	while(true){
		cin>>n; if(n==0) break;
		min_y = DBL_MAX;
		buy(0,0);
		cout<<int(min_y)<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(int n, res; res = INF, cin >> n, n /= 100; cout << res << endl)
        for(int c = 0; c <= n; c += 5)
            for(int b = 0, a; (b + c) <= n; b += 3)
                if(!((a = n - b - c) % 2))
                    res = min(res, int((c / 5 * 0.88+ c / 5 % 3 * 0.12) * 850
                                     + (b / 3 * 0.85+ b / 3 % 4 * 0.15) * 550
                                     + (a / 2 * 0.8 + a / 2 % 5 * 0.20) * 380));

    return 0;
}

C++: #include <iostream>
using namespace	std;
int main(){
  for(int n;cin>>n&&n;){
    int r=1e9;
    for(int c0=0;c0<=25;c0++)
      for(int c1=0;c1<=16;c1++)
        for(int c2=0;c2<=10;c2++)
          for(int c3=0;c3<=5;c3++)
            for(int c4=0;c4<=4;c4++)
              for(int c5=0;c5<=3;c5++)
                if(n==c0*200+c1*300+c2*500+c3*1000+c4*1200+c5*1500) r=min(r,c0*380+c1*550+c2*850+c3*1520+c4*1870+c5*2240);
    cout<<r<<endl;
  }
  return 0;
}

C++: #include<iostream>

const int q[3] = { 200, 300, 500 };
const int p[3] = { 380, 550, 850 };
const int b[3] = { 5, 4, 3 };
const double r[3] = { 0.8, 0.85, 0.88 };

int calc( int i, int n )
{
	return n / b[i] * b[i] * p[i] * r[i] + n % b[i] * p[i];
}

int main()
{
	int n;
	while( std::cin >> n, n )
	{
		int ans = 1 << 30;

		for( int a = 0; a <= 25; ++a )
		{
			for( int b = 0; b <= 16; ++b )
			{
				for( int c = 0; c <= 10; ++c )
				{
					int price = calc( 0, a ) + calc( 1, b ) + calc( 2, c );
					int w = a * q[0] + b * q[1] + c * q[2];

					if( w == n )
						ans = std::min( ans, price );
				}
			}
		}

		std::cout << ans << std::endl;
	}

	return 0;
}