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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  vi dp(5001, INF);
  rep(a, 30) rep(b, 30) rep(c, 30) {
    int s = 0;
    s += a % 5 * 380 + a / 5 * 5 * 380 * 80 / 100;
    s += b % 4 * 550 + b / 4 * 4 * 550 * 85 / 100;
    s += c % 3 * 850 + c / 3 * 3 * 850 * 88 / 100;
    int w = a * 200 + b * 300 + c * 500;
    if (w <= 5000) cmin(dp[w], s);
  }
  int n;
  while (cin >> n, n) cout << dp[n] << endl;
}

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<iostream>
#include<algorithm>
#define INF 1<<21
using namespace std;

int main(){
  int dp[5001];
  int items[]={200,300,500,1000,1200,1500};
  int prices[]={380,550,850,1520,1870,2244};
  int mg;
  for(int i=0;i<5001;i++){
    dp[i] = INF;
  }
  dp[0]=0;
  for(int i=0;i<6;i++){
    for(int j=0;j<5001-items[i];j++){
      dp[j+items[i]] = min(dp[j+items[i]],dp[j]+prices[i]);
    }
  }
  while(1){
    cin >> mg;
    if(mg == 0) break;
    cout << dp[mg] << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
#define INF ( 1 << 30 )

int main(){
  int dp[5001];
  int item[] = { 200 , 300 , 500 , 1000 , 1200 , 1500 };
  int price[]= { 380 , 550 , 850 , 1520 , 1870 , 2244 };
  fill_n(dp,5001,INF);
  dp[0] = 0;
  rep(i,6) rep(j,5001 - item[i]){
    dp[j + item[i]] = min ( dp[j + item[i]] , dp[j] + price[i] );
  }
  int n;
  while(cin >> n , n) cout << dp[n] << endl;
}

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

typedef long long ll;

using namespace std;

int main()
{
	int q[] = { 2, 3, 5 };
	int v[] = { 380, 550, 850 };
	int dq[] = { 5, 4, 3 };
	double dis[] = { 0.2, 0.15, 0.12 };
	int g;
	int vv[3][51];
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 51; ++j)
		{
			int sack = (j+q[i]-1) / q[i];
			int disSack = sack / dq[i] * dq[i];
			vv[i][j] = v[i]*sack - (int)(v[i]*disSack*dis[i]);
		}
	}
	int dp[3+1][51];
	for (int i = 0; i < 4; ++i)
		for (int j = 0; j < 51; ++j)
		dp[i][j] = 1000000;
	dp[0][0] = 0;
	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < 51; ++j)
			for (int k = 0; k+j < 51; ++k)
				dp[i+1][j+k] = min(dp[i+1][j+k], dp[i][j] + vv[i][k]);

	while (scanf("%d", &g), g)
		printf("%d\n", dp[3][g/100]);

	return 0;
}

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

typedef long long ll;

using namespace std;

int main()
{
	int q[] = { 2, 3, 5 };
	int v[] = { 380, 550, 850 };
	int dq[] = { 5, 4, 3 };
	double dis[] = { 0.2, 0.15, 0.12 };
	int vv[3][51];
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 51; ++j)
		{
			if (j % q[i] != 0)
			{
				vv[i][j] = 100000000;
				continue;
			}
			int sack = (j+q[i]-1) / q[i];
			int disSack = sack / dq[i] * dq[i];
			vv[i][j] = v[i]*sack - (int)(v[i]*disSack*dis[i]);
		}
	}

	int dp[3+1][51];
	for (int i = 0; i < 4; ++i)
		for (int j = 0; j < 51; ++j)
		dp[i][j] = 1000000;
	dp[0][0] = 0;

	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < 51; ++j)
			for (int k = 0; k+j < 51; ++k)
				dp[i+1][j+k] = min(dp[i+1][j+k], dp[i][j] + vv[i][k]);

	int g;
	while (cin >> g && g)
		cout << dp[3][g/100] << endl;

	return 0;
}

C++: #include<stdio.h>
int min(int a,int b){return a<b?a:b;}
int main(){
	while(1){
		int n;
		int i,j,k;
		scanf("%d",&n);
		if(n==0)return 0;
		int ans=1000000;
		int res1,res2;
		int cost1,cost2,cost3;
		for(i=0;i<(int)n/200+1;i++){
			cost1=0;
			cost2=0;
			cost3=0;
			res1=n-i*200;
			cost1=i*380-(int)(i/5)*380;
			for(j=0;j<(int)res1/300+1;j++){
				res2=res1-j*300;
				cost2=cost1+j*550-(int)(j/4)*330;
				for(k=(int)res2/500;k<(int)res2/500+1;k++){
					if(res2-k*500>0)break;
					else{
						cost3=cost2+k*850-(int)(k/3)*306;
						ans=min(ans,cost3);
					}
				}
			}
		}
		printf("%d\n",ans);
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define MAXVALUE (1<<21)
vector<int> dp(5000+1,MAXVALUE);

void init(){
	int item[6] = {200,300,500,1000,1200,1500};
	int price[6]= {380,550,850,1520,1870,2244};
	
	dp[0]=0;

	for(int k=0;k<6;k++){
		for(int i=0;i+item[k]<=5000;i++){
			dp[i+item[k]] = min( dp[i+item[k]] , dp[i]+price[k] );
		}
	}
}

int main(){
	init();
	int n,mi;
	while(cin >> n && n){
		mi = dp[n];
		/*for(int i=n;i<=5000;i++){
			mi = min(dp[i],mi);
		}*/
		cout << mi << endl;
	}
}