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 <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;
	}
}

C++: #include <iostream>

using namespace std;

int g;

void solve() {
	int A = g / 200, B = g / 300, C = g / 500;
	int ans = (int)1e9;
	
	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			if (200 * a + 300 * b > g) break;
			
			for (int c = 0; c <= C; c++) {
				if (200 * a + 300 * b + 500 * c > g) break;
				
				if (200 * a + 300 * b + 500 * c == g) {
					int unitA = a % 5, discA = a - unitA;
					int unitB = b % 4, discB = b - unitB;
					int unitC = c % 3, discC = c - unitC;
					
					int buyA = (380 * discA) * 0.8 + 380 * unitA;
					int buyB = (550 * discB) * 0.85 + 550 * unitB;
					int buyC = (850 * discC) * 0.85 + 850 * unitC;
					
					ans = min(ans, buyA + buyB + buyC);
				}
			}
		}
	}
	
	cout << ans << endl;
}

int main() {
	while (1) {
		cin >> g; if (g == 0) break;
		solve();
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int w[6]={2,3,5,10,12,15};
int v[6]={380,550,850,1520,1870,2244};
int dp[60];
const int INF=1e9;

signed main(){
	rep(i,0,60) dp[i]=INF;
	dp[0]=0;
	rep(i,0,6){
		for(int j=0;j+w[i]<=50;j++){
			dp[j+w[i]]=min(dp[j+w[i]],dp[j]+v[i]);
		}
	}
	//rep(i,0,60) o(dp[i]);
	int W;
	while(1){
		cin>>W;
		if(W==0) break;
		W/=100;
		o(dp[W]);
	}	
}

C++: #include <iostream>

using namespace std;

int main(){
  constexpr int n=3;
  int weight[n]={200,300,500};
  int price[n]={380,550,850};
  int discountnum[n]={5,4,3};
  double discount[n]={0.8,0.85,0.88};
  int w;
  while(cin>>w,w){
    int minprice=0x7fffffff;
    for(int i=0;i<n;i++){
      if(w%weight[i])continue;
      int num=w/weight[i];
      int p=double(price[i]*(num-num%discountnum[i]))*discount[i]
        +price[i]*(num%discountnum[i]);
      if(minprice>p)minprice=p;
    }
    cout<<minprice<<endl;
  }
}

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

using namespace std;

int ret;
int w;

void solve(int tmpw, int c){
  //cout << "tmpw = " << tmpw << endl;
  if(c >= ret) return;
  if(tmpw <= 0){
	ret = min(ret, c);
	return;
  }
  solve(tmpw-1500, c+850*3*0.88);
  solve(tmpw-1000, c+380*5*0.8);
  solve(tmpw-1200, c+550*4*0.85);
  if(tmpw <= 2000){
	solve(tmpw-500, c+850);
  }
  if(tmpw <= 1800){
	solve(tmpw-300, c+550);
  }
  if(tmpw <= 1700){
	solve(tmpw-200, c+380);
  }

  return;
}

int main(void){
  while(cin >> w && w){
	ret = 1 << 30;
	solve(w,0);
	cout << ret << endl;
  }
}

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 solve(int weight, int a, int b, int c)
{
	int sum = a*200 + b*300 + c*500;
	
	if(sum == weight)
		return a/5*1520 + a%5*380 + b/4*1870 + b%4*550 + c/3*2244 + c%3*850;
	
	int best = 1<<29;
	if(sum+200 <= weight)
		best = min(best, solve(weight, a+1, b, c));
	if(sum+300 <= weight)
		best = min(best, solve(weight, a, b+1, c));
	if(sum+500 <= weight)
		best = min(best, solve(weight, a, b, c+1));
	
	return best;
}

int main()
{
	int weight;
	while(scanf("%d", &weight), weight){
		printf("%d\n", solve(weight, 0, 0, 0));
	}
	
	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*(100-AP)/100+(a%AN)*AM + (b/BN)*BN*BM*(100-BP)/100+(b%BN)*BM + (c/CN)*CN*CM*(100-CP)/100+(c%CN)*CM;
		if(money<work){money=work;}
	  }
	 }
	 
	 cout<<money<<endl;
	}
	return 0;
}

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

int main()
{
    int weight[6] = {2,3,5,10,12,15};
    int price[6] = {380,550,850,1520,1870,2244};
    int dp[52];
    int a=0;
    for(int i=0;i<52;i++){
        dp[i] = 1000000000;
    }
    dp[0] = 0;

    for(int i=0;i<52;i++){
        for(int j=0;j<6;j++){
            if(i-weight[j] >= 0)
                dp[i] = min(dp[i],dp[i-weight[j]]+price[j]);
        }
    }
    int n;
    while(cin >> n){
        if(n==0)
            break;
        cout << dp[n/100] << endl;
    }
    return 0;
}

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

int main(){
  int n;

  while(cin>>n,n){
    int ans = INT_MAX;
    for(int i=0;i*200<=n;i++){
      int aw = i * 200;
      for(int j=0;aw+j*300<=n;j++){
        int bw = j * 300;
        for(int k=0;aw+bw+k*500<=n;k++){
          int cw = k * 500;
          if(aw+bw+cw < n) continue;

          int calA = (i % 5) * 380 + (i / 5) * 5 * 380 * 0.8;
          int calB = (j % 4) * 550 + (j / 4) * 4 * 550 * 0.85;
          int calC = (k % 3) * 850 + (k / 3) * 3 * 850 * 0.88;

          ans = min(ans,calA+calB+calC);
        }
      }
    }

    cout<<ans<<endl;
  }
}