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 <limits.h>
using namespace std;

struct Comodity{
	int weight, price, unit;
	double rate;
};

Comodity com_list[] = {
	{ 200, 380, 5, 0.8 },
	{ 300, 550, 4, 0.85 },
	{ 500, 850, 3, 0.88 },
};

enum{
	A,
	B,
	C,
};

int quantity( int remain, int unit_weight ){
	return remain / unit_weight;
}

int calcPrice( int a, int b, int c ){
	int dis_a = a / com_list[ A ].unit * com_list[ A ].unit;
	int dis_b = b / com_list[ B ].unit * com_list[ B ].unit;
	int dis_c = c / com_list[ C ].unit * com_list[ C ].unit;
	a -= dis_a;
	b -= dis_b;
	c -= dis_c;
	return ( a * com_list[ A ].price ) + ( b * com_list[ B ].price ) + ( c * com_list[ C ].price )
		+ (int)( dis_a * com_list[ A ].price * com_list[ A ].rate )
		+ (int)( dis_b * com_list[ B ].price * com_list[ B ].rate )
		+ (int)( dis_c * com_list[ C ].price * com_list[ C ].rate );
}

int main()
{
	int weight;

	while( cin >> weight && weight ){
		int best_price = INT_MAX;
		int remain_a = weight;
		int a = quantity( remain_a, com_list[ A ].weight );
		for( ; a >= 0; --a ){
			int remain_b = remain_a - a * com_list[ A ].weight;
			int b = quantity( remain_b, com_list[ B ].weight );
			for( ; b >= 0; --b ){
				int remain_c = remain_b - b * com_list[ B ].weight;
				int c = quantity( remain_c, com_list[ C ].weight );
				if( remain_c - c * com_list[ C ].weight != 0 ){
					continue;
				}
				best_price = min( best_price, calcPrice( a, b, c ) );
			}
		}
		cout << best_price << endl;
	}

	return 0;
}

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

#define loop for (;;)
#define repeat(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  pair<int, int> prices[6] = {
    make_pair(2, 380),
    make_pair(3, 550),
    make_pair(5, 850),
    make_pair(2 * 5, 380 * 5 * 80 / 100),
    make_pair(3 * 4, 550 * 4 * 85 / 100),
    make_pair(5 * 3, 850 * 3 * 88 / 100)
  };
  int dp[51] = {0};
  fill(dp+1, dp+51, 100000);
  for (int i = 2; i <= 50; i++)
    repeat(j, 6)
      if (i - prices[j].first >= 0)
        dp[i] = min(dp[i], dp[i-prices[j].first] + prices[j].second);
      else
        break;
  loop {
    int needed;
    cin >> needed;
    if (!needed) return 0;
    cout << dp[needed / 100] << endl;
  }
}

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 main() {
	int x;
	while (cin >> x, x) {
		int ans = INF;
		REP(i, 5000/200 + 1) REP(j, 5000/300 + 1) REP(k, 5000/500 + 1) if (i*200+j*300+k*500 == x) {
			int tmp = int(i / 5 * (380 * 0.8) * 5 + i % 5 * 380
					+ j / 4 * (550 * 0.85) * 4 + j % 4 * 550
					+ k / 3 * (850 * 0.88) * 3 + k % 3 * 850);
			if (tmp == 0) continue;
			ans = min(ans, tmp);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<climits>
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 <algorithm>
 
using namespace std;
 
const int inf = 999999;
 
int main()
{
  int n;
  int r = inf, w;
 
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 17; j++){
      for(int k = 0; k <= 10; k++){
    w = i*200+j*300+k*500;
    if(n == w){
      r = min(r, (i/5)*1520 + (i%5)*380 + 1870*(j/4) + (j%4)*550 + 2244*(k/3) + (k%3)*850);
    } else if(n < w){
      break;
    }
      }
    }
  }

C++: #include<iostream>
#define INF 1000000000
using namespace std;
int main(){
	int m[]={380,550,850,1520,1870,2244},
	dp[100010],
	w[]={2,3,5,10,12,15};
	for(int i=0;i<=100005;i++)
		dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<6;i++)
	for(int j=w[i];j<=100005;j++){
		//if(dp[j-w[i]]==INF)
		//dp[j]=min(m[i],dp[j]);
		//else
		dp[j]=min(dp[j],dp[j-w[i]]+m[i]);
	//	if(j==22)
		//cout<<i<<' '<<dp[j]<<endl;
	}
	//for(int i=0;i<=2500;i++)
	//cout<<' '<<dp[i]<<endl;
	int n;
	while(cin>>n,n){
		n/=100;
		int ans=dp[n];
		/*for(int i=n;i<=100005;i++){
			if(dp[i]!=INF)
			ans=min(ans,dp[i]);
		}*/
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

const int INF = 2<<20;

int main(){
	int w[] = {2, 3, 5};
	int v[] = {380, 550, 850};
	int disn[] = {5, 4, 3};
	double disp[] ={0.2, 0.15, 0.12};

	int lowest[55];
	fill(lowest, lowest+55, INF);
	lowest[0] = 0;

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 50; j++){
			for(int k = 1; j + w[i]*k <= 50; k++){
				int n = k - k%disn[i];
				lowest[j+w[i]*k] = min(lowest[j+w[i]*k], lowest[j]+v[i]*(k-n)+(int)(v[i]*n*(1.0-disp[i])));
			}
		}
	}

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

	return 0;
}

C++: 
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  vi dp(51,INF);
  vi v(6),c(6);
  c[0]=380;
  c[1]=550;
  c[2]=850;
  c[3]=380*4;
  c[4]=550*4*85/100;
  c[5]=850*3*88/100;
  v[0]=2;
  v[1]=3;
  v[2]=5;
  v[3]=10;
  v[4]=12;
  v[5]=15;

  dp[0]=0;

  rep(i,25)rep(j,50)if(dp[j]<INF){
    rep(k,6)if(j+v[k]<=50)
      dp[j+v[k]]=min(dp[j+v[k]],dp[j]+c[k]);
  }

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

C++: #include <iostream>
#include <algorithm>
#define MAX 5000

using namespace std;

int dp[MAX + 1];
int weight[6] = { 200 , 300 , 500 , 1000 , 1200 , 1500 };
int value[6] = { 380 , 550 , 850 , 1520 , 1870 , 2244};

void compute(void){

  for( int i = 0 ; i <= MAX ; i++ ) dp[i] = MAX;
  dp[0] = 0;
  for( int i = 0 ; i < 6 ; i++ ){
    for( int j = 0 ; j <= MAX ; j++ ){
      if( j + weight[i] <= MAX ){
	dp[j + weight[i]] = min( dp[j + weight[i]] , dp[j] + value[i] );
      }
      // 値段はvalueの6種類のみだからづいじそのパターンで計算
    }
  }

}

int main(void){

  compute();

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