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 <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 + (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+=50) {
        for (int j = 0; j <= n; j+=50) {
            for (int k = 0; k <= n; k+=50) {
                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;
}

C++: #include<cstdio>
#include<algorithm>

using namespace std;

int price(int a,int b,int c)
{
	int na=a/200,nb=b/300,nc=c/500;
	int pa=1520*(na/5)+380*(na%5);
	int pb=1870*(nb/4)+550*(nb%4);
	int pc=2244*(nc/3)+850*(nc%3);
	return pa+pb+pc;
}

int main()
{
	int g;
	while(scanf("%d",&g),g){
		int pmin=10000000;
		for(int c=0;c<=g/500*500;c+=500){
			for(int b=0;b+c<=g;b+=300){
				int a=g-(b+c);
				if(a%200==0){
					pmin=min(pmin,price(a,b,c));
				}
			}
		}
		printf("%d\n",pmin);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main( ){
  while(1){
    int n,sum=0,a,b,c,sa=0,min,a1=0,a2=0,a3=0;
  cin>>n;
  if(n==0)break;
  if(n>=1000){
    for(int i=0;i<=5;i++){
      for(int j=0;j<=5;j++){
        for(int q=0;q<=5;q++){
          sa=n-i*1500-j*1200-q*1000;
          if(i==0&&j==0&&q==0)min=sa;
          if(sa>=0&&sa!=100&&sa<=min){
            min=sa;
            a1=i;
          a2=j;
          a3=q;
          }
        }
      }
    }
  }
  sum+=850*3*a1*0.88;
  sum+=550*4*a2*0.85;
  sum+=380*5*a3*0.8;
  n-=1500*a1;
  n-=1200*a2;
  n-=1000*a3;
  a=n/500;
  if(n%500==100)a--;
  sum+=850*a;
  n-=a*500;
  c=n/300;
  if(n%300==100)c--;
  sum+=550*c;
  n-=c*300;
  b=n/200;
  if(n%200==100)b--;
  sum+=380*b;
  cout<<sum<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#define INF 1000000000

int price;
int dp[11][11][11]; // dp table
int weight;

void solve(int a, int b, int c) {
  if (dp[a][b][c] != INF)
    return;

  int w = a*200 + b*300 + c*500;
  int calc_price = 
    ((a/5)*5) * 380 * 0.8 + (a%5)*380
    + ((b/4)*4) * 550 * 0.85 + (b%4)*550
    + ((c/3)*3) * 850 * 0.88 + (c%3)*850;

  
  if (weight == w) {
    if (price >= calc_price) {
      price = calc_price;
      dp[a][b][c] = calc_price;
    }
    return;
  } else if (weight < w) {
    return;
  } else {
    solve(a+1, b, c);
    solve(a, b+1, c);
    solve(a, b, c+1);
  } 
}

int main() {
  while(scanf("%d", &weight), weight) {
    for (int i=0; i<11; i++)
      for (int j=0; j<11; j++)
	for (int k=0; k<11; k++)
	  dp[i][j][k] = INF;
    
    price = INF;
    solve(0,0,0);

    printf("%d\n", price);
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

const double INF = 1e9;
double cost[6000];

double calc(int i, int j, int k) {
    return (380 * ((i / 5) * 5 * 0.8  + (i % 5)) +
            550 * ((j / 4) * 4 * 0.85 + (j % 4)) +
            850 * ((k / 3) * 3 * 0.88 + (k % 3)));
}

int main(void) {
    fill(cost, cost + 6000, INF);

    int n = 5000, sum;
    for (int i = 0; 200 * i <= n; i++)
        for (int j = 0; 300 * j <= n - 200 * i; j++)
            for (int k = 0; 500 * k <= n - i * 200 - j * 300; k++) {
                sum = 200 * i + 300 * j + 500 * k;
                cost[sum] = min(cost[sum], calc(i, j, k));
            }
    
    while (scanf("%d", &n), n)
        printf("%d\n", (int)cost[n]);

    return 0;
}

C++: #include<iostream>

using namespace std;

const int MAX = 5001;
const int INF = (1<<20);

int dp[MAX];
int price[2][6] = {
  {200,1000,300,1200,500,1500},
  {380,(380*5)*0.8,550,(550*4)*0.85,850,(850*3)*0.88}
};

void make(){

  fill(dp,dp+MAX,INF);

  for(int i = 0; i < 6; i++)
    dp[price[0][i]] = price[1][i];


  for(int i = 100; i < MAX; i+=100)
    for(int j = 0; j < 6; j++)
      if(i-price[0][j] >=0)
	dp[i] = min(dp[i],dp[i-price[0][j]]+price[1][j]);

    
     
}

int main(){
  int in;
  make();
  while(cin >> in && in) cout << dp[in] << 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(n){ while(cin >> n, n) cout << solve(n) << endl; }

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int m[] = {200, 300, 500};
int p[] = {380, 550, 850};
int d[] = {5, 4, 3};
double r[] = {0.8, 0.85, 0.88};
const int INF = 1 << 30;

int dfs(int k, int rest)
{
    if(rest == 0) return 0;
    
    if(k == 3 || rest < 0) return INF;
    
    int res = INF;
    for(int i = 0; i <= 40; i++)
        chmin(res, dfs(k + 1, rest - m[k] * i) + p[k] * (i - i % d[k]) * r[k] + p[k] * (i % d[k]));
    
    return res;
}

int main()
{
	int v;
	while(cin >> v && v)
        cout << dfs(0, v) << endl;
}