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 ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  double ans;
  vary(double,dp,51,0);
  dp[0] = 0;
  dp[1] = inf;
  dp[2] = 380;
  dp[3] = 550;
  dp[4] = 380*2;
  dp[5] = 850;
  dp[6] = 550 * 2;
  REP(i,7,51){
    ans = 380 + dp[i-2];
    ans = min(ans,550 + dp[i-3]);
    ans = min(ans,850 + dp[i-5]);
    if(i >= 10)
      ans = min(ans,dp[i-10] + 380 * 5 * 0.8);
    if(i >= 12)
      ans = min(ans,dp[i-12] + 550 * 4 * 0.85);
    if(i >= 15)
      ans = min(ans,dp[i-15] + 850 * 3 * 0.88);
    dp[i] += ans;
  }
  while(cin>>n&&n){
    cout << dp[n/100] << endl;
  }
  return 0;
}

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

const int INF = 1 << 30;

int gram;
int memo[30][30][30];

int solve(int A, int B, int C)
{
  if (memo[A][B][C] != -1)
    return memo[A][B][C];
  else if (A*200 + B*300 + C*500 > gram)
    return INF;
  else if (A*200 + B*300 + C*500 == gram)
    return A/5*1520 + (A%5)*380 + B/4*1870 + (B%4)*550 + C/3*2244 + (C%3)*850;

  int ret = std::min(solve(A+1, B, C), std::min(solve(A, B+1, C), solve(A, B, C+1)));
  return memo[A][B][C] = ret;
}

int main()
{
  while (~scanf("%d", &gram)) {
    if (gram == 0)
      break;

    for (int i = 0; i < 30; ++i) {
      for (int j = 0; j < 30; ++j) {
	for (int k = 0; k < 30; ++k)
	  memo[i][j][k] = -1;
      }
    }
    printf("%d\n", solve(0, 0, 0));
  }
  return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

int weight[6] = {200,300,500,1000,1200,1500};
int price[6]  = {380,550,850,1520,1870,2244}; 




int main(void){
	int n;
	while(scanf("%d", &n) &&n ){
		int dp[200001] ={0};
		dp[0] = 0;
		
		for(int i = 1; ; i++){
			for(int j = 0; j < 6; j++){
				if(i-price[j] < 0)continue;
				dp[i] = max(dp[i-price[j]]+weight[j],dp[i]);
			}
			if(dp[i]>=n){
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

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

//?????????
#define AG 200
#define BG 300
#define CG 500
//?????????
#define AM 380
#define BM 550
#define CM 850
//??????????????????
#define AN 5
#define BN 4
#define CN 3
//??????????????????
#define AP 20
#define BP 15
#define CP 12

int main(){
	int g;
	int a,b,c;
	int total;
	int money,work;
	
	while(1){
	 cin>>g;
	 if(g==0){break;}
	 a=0;b=0;c=0;
	 total=0;money=0;
	 
	 for(c=0;c*CG<=g;c++){
	  for(b=0;c*CG+b*BG<=g;b++){
		total=c*CG+b*BG;
		a=(g-total)/200;
		total+=a*AG;
		if(total!=g){continue;}
		//???????¨????
		work=(a/AN)*AN*AM*AP/100+(a%AN)*AM + (b/BN)*BN*BM*BP/100+(b%BN)*BM + (c/CN)*CN*CM*CP/100+(c%CN)*CM;
		if(money<work){money=work;}
	  }
	 }
	 
	 cout<<money<<endl;
	}
	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int dp[10000];
	for (int i = 0; i < 10000; ++i) {
		dp[i] = 1e9;
	}
	dp[0] = 0;
	for (int i = 0; i <= 5000; ++i) {
		dp[i + 200] = min(dp[i + 200], dp[i] + 380);
		dp[i + 300] = min(dp[i + 300], dp[i] + 550);
		dp[i + 500] = min(dp[i + 500], dp[i] + 850);
		dp[i + 1000] = min(dp[i + 1000], dp[i] + 380 * 4);
		dp[i + 1200] = min(dp[i + 1200], dp[i] + 1870);
		dp[i + 1500] = min(dp[i + 1500], dp[i] + 2244);
	}
	for (int i = 9998; i >=0;--i) {
		dp[i] = min(dp[i + 1], dp[i]);
	}
	while (1) {
		int N; cin >> N;
		if (!N)break;
		cout << dp[N] << endl;
	}
	return 0;
}

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

#define min(a, b) b < a ? b : a
#define INF (10000000)

int money[51];

void set(void);

int main(void)
{
    int g;
    
    for (int i = 0; i < 51; i++){
        money[i] = INF;
    }
    
    set();
    while (1){
        scanf("%d", &g);
        if (g == 0) break;
        
        g /= 100;
        printf("%d\n", money[g]);
    }
}

void set(void)
{
    for (int i = 0; i < 26; i++){
        for (int j = 0; j < 18; j++){
            for (int k = 0; k < 11; k++){
                if((i * 2) + (j * 3) + (k * 5) < 51){
                    money[(i * 2) + (j * 3) + (k * 5)] = min(money[(i * 2) + (j * 3) + (k * 5)], (i / 5) * 1520 + (i % 5) * 380 + (j / 4) * 1870 + (j % 4) * 550 + (k / 3) * 2244 + (k % 3) * 850);
                }
            }
        }
    }
    
    
}

C++: #include <iostream>

using namespace std;

int memo[5001];
void init(){
  fill(memo, memo+5001, 1<<20);
  for(int i = 0; i*200 <= 5000 ; i++){
    for(int j = 0; j*300 <= 5000 ; j++){
      if(i*200+j*300 > 5000)break;
      for(int k = 0; k*500 <= 5000 ; k++){
	if(i*200+j*300+k*500 > 5000)break;
	int sum = i*200+j*300+k*500;
	int m = (i/5)*1520+(i%5)*380 + (j/4)*1870+(j%4)*550 + (k/3)*2244 + (k%3)*850;
	memo[sum] = min(memo[sum], m);
      }
    }
  }
}
int main(){
  int n;
  init();
  while(cin >> n, n){
    cout << memo[n] << endl;
  }
  return 0;
}