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 iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int cost_a (int n) {
  int r = (n % 5) * 380;
  r += (n - (n%5)) * 38 * 8;
  return r;
}

int cost_b (int n) {
  int r = (n % 4) * 550;
  r += (n - (n % 4)) * 55 * 85 / 10;
  return r;
}

int cost_c (int n) {
  int r = (n%3)*850;
  r += (n-(n%3)) * 88 * 85 / 10;
  return r;
}

int main() {
  for (;;) {
    int c; cin >> c;
    if (c == 0) break;
    c /= 100;
    trace(c);
    int mc = INF;
    rep (i, 1 + c/2) {
      rep (j, 1 + c/3) {
        rep (k, 1 + c/5) {
          if (2 * i + 3 * j + 5 * k == c) {
            int cc = cost_a(i) + cost_b(j) + cost_c(k);
            mc = min(mc, cc);
          }
        }
      }
    }
    cout << mc << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int getWeight(int a, int b, int c) {
  return a*200 + b*300 + c*500;
}

int getMoney(int a, int b, int c) {
  int res = 0;
  
  int a_ori = a%5;
  int a_dis = a/5*5;
  res += a_dis*380*0.80 + a_ori*380;
  
  int b_ori = b%4;
  int b_dis = b/4*4;
  res += b_dis*550*0.85 + b_ori*550;
  
  int c_ori = c%3;
  int c_dis = c/3*3;
  res += c_dis*850*0.88 + c_ori*850;
  
  return res;
}

int main() {
  int N;
  while(cin >> N && N) {
    int ans = (int)1e9;
    for(int i=0; i<30; i++)
      for(int j=0; j<30; j++)
	for(int k=0; k<30; k++)
	  if(getWeight(i, j, k) == N) {
	    ans = min(ans, getMoney(i, j, k));
	  }
    
    cout << ans << endl;
  }
  
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int buy_A(int n){
	return 380*(n-n%5)*0.80 + 380 * (n%5);
}

int buy_B(int n){
	return 550*(n-n%4)*0.85 + 550 * (n%4);
}

int buy_C(int n){
	return 850*(n-n%3)*0.88 + 850 * (n%3);
}

int main(){
	int W;
	while(~scanf("%d",&W)){
		if(W==0) break;
		W/=100;
		int res=100000000;

		for(int a=0; a<=25;a++){
			for(int b=0; b<=17;b++){
				for(int c=0; c<=10;c++){
					if(W-a*2-b*3-c*5 == 0){
						res = min(res,buy_A(a)+buy_B(b)+buy_C(c));
					}

				}
			}

		}

		cout << res << endl;

	}
}

C++: #include <iostream>

using namespace std;

int soba[][2] = {
	{1200, 1870},
	{1000, 1520},
	{1200, 1870},
	{1000, 1520},
	{500, 850},
	{300, 550},
	{200, 380}
};

int main() {
	int n;
	cin >> n;
	if (n) {
		int ans = 0;
		for (int i = 0; i < 6; i++) {
			ans += n / soba[i][0] * soba[i][1];
			n %= soba[i][0];
		}
		if (n) {
			ans += soba[5][0];
		}
		cout << ans << endl;
		main();
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#define INF (1<<24)
using namespace std;
int n,ans;
int checkA(int);
int checkB(int);
int checkC(int);

int main(){
  while(cin>>n){
    if(n==0)break;
    ans=INF;
    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	for(int k=0;k<100;k++){
	  if(i*200+j*300+k*500>=n){	    
	    ans=min(checkA(i)+checkB(j)+checkC(k),ans);
	  }
	}
      }
    }    
    cout<<ans<<endl;
  }
  return 0;
}
int checkA(int cnt){
  int x = cnt / 5, y = cnt % 5;
  return x*1520+y*380;
}

int checkB(int cnt){
  int x = cnt / 4, y = cnt % 4;
  return x*1870+y*550;
}

int checkC(int cnt){
  int x = cnt / 3, y = cnt % 3;
  return x*2244+y*850;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int dp[50005][3];
#define INF 2000000000
int main(){
	int n;
	while(scanf("%d",&n) && n){
		for(int i=1;i<50005;i++){
			for(int j=0;j<3;j++){
				dp[i][j]=INF;
			}
		}
		for(int i=1;i<=30;i++){
			dp[200*i][0]=380*i-(i/5)*380;
		}
		for(int i=0;i<=50000;i++){
				for(int j=0;j<=i/300;j++){
					dp[i][1]=min(dp[i][1],dp[i-300*j][0]+550*j-(j/4)*330);
				}
		}
		for(int i=0;i<=50000;i++){
				for(int j=0;j<=i/500;j++){
					dp[i][2]=min(dp[i][2],dp[i-500*j][1]+850*j-(j/3)*306);
				}
		}
		printf("%d\n",dp[n][2]);
	}
}

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);
			ans = min(ans, tmp);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>

using namespace std;

int n;

int price[3]={200,300,500};
int min_price;


int price_cal(int a, int b, int c){
    int ret=0;
    ret+=(a-a%5)*380*0.8 +a%5*380;
    ret+=(b-b%4)*550*0.85+b%4*550;
    ret+=(c-c%3)*850*0.88+c%3*850;
    //cout<<a<<" "<<b<<" "<<c<<endl;;
    return ret;
}

void soba(int a, int b, int c, int now){
    if(a*200+b*300+c*500==n){
        min_price=min(min_price,price_cal(a, b, c));
    }else if(a*200+b*300+c*500>n){
        
    }else{
        if(now==0){
            soba(a+1,b,c,0);
            soba(a,b+1,c,1);
            soba(a,b,c+1,2);
        }else if(now==1){
            soba(a,b+1,c,1);
            soba(a,b,c+1,2);
        }else{
            soba(a,b,c+1,2);
        }
    }
    
}





int main(){
    while(cin>>n){
        if(n==0)break;
        min_price=100000000;
        soba(0, 0, 0, 0);
        cout<<min_price<<endl;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int n;

int main(){
	while(cin>>n){
		if(n==0)return 0;
		int ans=9999;
		for(int i=0;i<26;i++)
		for(int j=0;j<26;j++)
		for(int k=0;k<26;k++){
			int w=200*i+300*j+500*k,v=380*0.8*(i-(i%5))+380*(i%5)+550*0.85*(j-(j%4))+550*(j%4)+850*0.88*(k-(k%3))+850*(k%3);

			if(w>=n)ans=min(ans,v);
		}
		cout<<ans<<endl;
	}
}