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 <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int answers[64];
	int dp[64][8][4][4];
	
	rep(i, 51){
		answers[i] = 1<<29;
		rep(j, 5) rep(k, 4) rep(l, 3){
			int ans = i+j+k+l ? 1<<29 : 0;
			if(2<=i && j)
				ans = min(ans, dp[i-2][j-1][k][l] + 380);
			if(10<=i && !j)
				ans = min(ans, dp[i-9][0][k][l] + 1520);
			if(3<=i && k)
				ans = min(ans, dp[i-3][j][k-1][l] + 550);
			if(12<=i && !k)
				ans = min(ans, dp[i-12][j][0][l] + 1870);
			if(5<=i && l)
				ans = min(ans, dp[i-5][j][k][l-1] + 850);
			if(15<=i && !l)
				ans = min(ans, dp[i-15][j][k][0] + 2244);
			dp[i][j][k][l] = ans;
			answers[i] = min(answers[i], ans);
		}
	}
	
	int weight;
	while(scanf("%d", &weight), weight){
		printf("%d\n", answers[weight/100]);
	}
	
	return 0;
}

C++: // 0-1 knapsack
#include<iostream>
#include<cstring>
using namespace std;

const int INF = (1<<21);

int main(){
    int w[7] = {0, 2, 3, 5, 10, 12, 15};
    int c[7] = {0, 380, 550, 850, 1520, 1870, 2244};

    int dp[7][51] = {};
    for(int i = 0; i < 7; i++){
        for(int j = 1; j < 51; j++){
            dp[i][j] = INF;
        }
    }

    for(int i = 1; i < 7; i++){
        for(int j = 1; j <= 50; j++){
            if(w[i] > j)    dp[i][j] = dp[i-1][j];
            else            dp[i][j] = min(dp[i-1][j], dp[i][j-w[i]]+c[i]); 
        }
    }

    int kg;
    while(cin >> kg){
        if(kg == 0) break;
        cout << dp[6][kg/100] << endl;
    }

    return 0;
}

C++: #include<bits/stdc++.h>
#define r(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(){
	int d[60],x;
	r(i,0,60)d[i]=9999;
	r(i,0,30)d[i*2]=380*i-380*(i/5);
	r(i,0,55)r(j,0,(55-i)/3)d[j*3+i]=min(d[j*3+i],d[i]+j*550-330*(j/4));
	r(i,0,55)r(j,0,(55-i)/5)d[j*5+i]=min(d[j*5+i],d[i]+j*850-306*(j/3));
	while(cin>>x&&x)cout<<d[x/100]<<endl;
	return 0;
}

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

int main() {
  int combi[100000][3] = {0},m=0;
  int input,price[100000] = {0},weight;
  int a,b,c,a1,b1,c1;

  while(cin >> input) {
    if(input == 0) break;
    for(int i=0;i<26;i++) {//generate combination of weight over input
      for(int j=0;j<17;j++) {
        for(int k=0;k<11;k++) {
          weight = 200*i + 300*j + 500*k;
          //cout << weight << " ";
          if(input <= weight) {
            combi[m][0] = i;
            combi[m][1] = j;
            combi[m][2] = k;
            //cout << combi[m][0] << " " <<  combi[m][1] << " " << combi[m][2] << endl;
            m++;
          }
        }
      }
    }




    for(int i=0;i<m;i++) {//calculate price[i] from combi[i]
      a = combi[i][0] / 5;//sale
      a1 = combi[i][0] - a*5;//not sale
      b = combi[i][1] / 4;//sale
      b1 = combi[i][1] - b*4;//not sale
      c = combi[i][2] / 3;//sale
      c1 = combi[i][2] - c*3;//not sale
      price[i] = 1520 * a + 380 * a1 + 1870 * b + 550 * b1 + 2244 * c + 850 * c1;
      //      cout << price[i] << endl;
    }

    sort(price,price+m);

    cout << price[0] << endl;
    m=0;
    int price[100000] = {0};
  }
}

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

using namespace std;

int priceA(int amount){
	if(amount % 200 != 0){ return -1; }
	amount /= 200;
	return (amount / 5 * 5) * 380 * 80 / 100 + (amount % 5) * 380;
}
int priceB(int amount){
	if(amount % 300 != 0){ return -1; }
	amount /= 300;
	return (amount / 4 * 4) * 550 * 85 / 100 + (amount % 4) * 550;
}
int priceC(int amount){
	if(amount % 500 != 0){ return -1; }
	amount /= 500;
	return (amount / 3 * 3) * 850 * 88 / 100 + (amount % 3) * 850;
}

int main(){
	while(true){
		int amount;
		cin >> amount;
		if(amount == 0){ break; }
		int price = INT_MAX;
		for(int a = 0; a <= amount; a += 200){
			for(int b = 0; b + a <= amount; b += 300){
				for(int c = 0; c + b + a <= amount; c += 500){
					if(a + b + c != amount){ continue; }
					int pa = priceA(a), pb = priceB(b), pc = priceC(c);
					price = min(price, pa + pb + pc);
				}
			}
		}
		cout << price << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

int main(){
	int n;
	int m[]={2,3,5,10,12,15,};
	int v[]={380,550,850,1520,1870,2244,};
	int dp[5000];
	rep(i,51)dp[i]=99999;
	rep(i,6)dp[m[i]]=v[i];
	rep(i,51){
		rep(j,6){
			int t=dp[i]+v[j];
			dp[i+m[j]]=min(dp[i+m[j]],t);
		}
	}
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",dp[n/100]);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int f(int a, int b, int c) {
	int r = 0;
	r += (a % 5) * 380;
	r += (a / 5) * 1520;
	r += (b % 4) * 550;
	r += (b / 4) * 1870; 
	r += (c % 3) * 850;
	r += (c / 3) * 3740;
	return r;
}
int main() {
	int n;
	while (cin >> n, n) {
		int ans = 114514;
		for (int i = 0; i <= 10; i++) {
			for (int j = 0; j <= 10; j++) {
				for (int k = 0; k <= 10; k++) {
					if (i * 200 + j * 300 + k * 500 == n)ans = min(ans, f(i, j, k));
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

int dp[51];
int data[2][6] = {{ 2, 3, 5, 10, 12, 15 }, {380, 550, 850, 1520, 1870, 2244}};

int main() {
	fill(dp, dp + 51, INF);
	dp[0] = 0;
	REP(i, 6) {
		REP(j, 51) {
			if (j - data[0][i] >= 0)
				dp[j] = min(dp[j], dp[j - data[0][i]] + data[1][i]);
		}
	}
	
	int x;
	while (cin >> x, x) cout << dp[x / 100] << endl;
	return 0;
}