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 <stdio.h>
#include <algorithm>
using namespace std;
int n, ret;
int main() {
    while(true) {
        scanf("%d", &n);
        if(n == 0) break;
        ret = 999999999;
        for(int a = 0; a <= 13; a++) {
            for(int b = 0; b <= 9; b++) {
                for(int c = 0; c <= 5; c++) {
                    int value = a * 200 + b * 300 + c * 500;
                    if(n == value) {
                        ret = min(ret, (a / 5) * 1520 + (a % 5) * 380 + (b / 4) * 1870 + (b % 4) * 550 + (c / 3) * 2244 + (c % 3) * 850);
                    }
                }
            }
        }
        printf("%d\n", ret);
    }
    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 main() {
    while(1){
      int n;
      cin >> n;
      if(n==0) break;
      int min = 1000000;
      int fee;
      for(int a=0;a<=n/200+1;a++){
	for(int b=0;b<=n/300+1;b++){
	  for(int c=0;c<=n/500+1;c++){
	    if(a*200+b*300+c*500==n){
	      fee=a*380+b*550+c*850;
	    if(a>=5) fee+=((a/5)*5*380)*0.8-(a/5*5*380);
	  if(b>=4) fee+=((b/4)*4*550)*0.85-(b/4*4*550);
	if(c>=3) fee+=((c/3)*3*850)*0.88-(c/3*3*850);
      if(min>fee) min=fee;
	    }
	  }
	}
      }	
      cout << min <<endl;
     } 
   return 0;
    }

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

using namespace std;

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

int main() {
	int n, m = 5000 * 500;
	cin >> n;
	if (n == 0){
		return 0;
	}
	for (int i = n / soba[2][0] + 5; i >= 0; i--) {
		for (int j = n / soba[1][0] + 5; j >= 0; j--) {
			for (int k = n / soba[0][0] + 5; k >= 0; k--) {
				int w = i * soba[2][0] + j * soba[1][0] + k * soba[0][0];
				if (w >= n) {
					int p = (int)(i / 3 * 3 * soba[2][1] * 0.88) + (int)(i % 3 * soba[2][1]) + (int)(j / 4 * 4 * soba[1][1] * 0.85) + (int)(j % 4 * soba[1][1]) + (int)(k / 5 * 5 * soba[0][1] * 0.8) + (int)(k % 5 * soba[0][1]);
					if (p < m) {
						m = p;
					}
				}
			}
		}
	}
	cout << m << endl;
	return main();
}

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=INF;
		for(int i=n;i<=100005;i++){
			if(dp[i]!=INF)
			ans=min(ans,dp[i]);
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[7][60001];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int price,weight;
    int w[6] = {2, 3, 5, 10, 12, 15};
    int v[6] = {380, 550, 850, 1520, 1870, 2244};

    fill(dp[0], dp[0] + 60001, 0);
    dp[0][0] = 0;
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j <= 60000; j++) {
            if (j < v[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - v[i]] + w[i]);
            }
        }
    }
    int m[51];
    fill(m, m+51, INF);
    for (int j = 0; j <= 20000; j++) {
        if (dp[5][j] != INF) {
            //printf("%d:%d\n", dp[5][j]*100, j);
        }
        if (dp[5][j] <= 50) {
            m[dp[5][j]] = min(m[dp[5][j]], j);   
        }   
    }
    /*
    for (int i = 0; i <= 50; i++) {
        printf("%d:%d\n", i*100, m[i]);
    }
    //*/

    cin >> weight;
    while (weight != 0) {
        cout << m[weight/100] << endl;
        cin >> weight;
    }
    
    return 0;
}

C++: #include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int wg;
int ryo[]={200,300,500,1000,1200,1500};
int plc[]={380,550,850,0,0,0};	

	plc[3]=380*5*0.8; plc[4]=550*4*0.85; plc[5]=850*3*0.88;
	rep(i,6) ryo[i] /= 100;

	while(cin >> wg ){
		if(wg==0 || cin.eof()) break;
		wg /= 100;
		vector<int>dp(wg+1,1<<22);
		dp[0]=0;
	rep(i,6) for(int j=0;j+ryo[i]<=wg; j++){
		dp[j+ryo[i]] = min( dp[j+ryo[i]] , dp[j]+plc[i] );
	}
	cout << dp[wg] << endl;
	}
	
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int frower[7][2] = {{0,0},{2,380},{3,550},{5,850},{10,1520},{12,1870},{15,2244}};
  int dp[51][7] = {0};
  for(int i=0; i<51; i++){
    for(int j=0; j<7; j++){
      dp[i][j] = 100000;
    }
  }
  for(int i=0; i<51; i++){
    for(int j=1; j<7; j++){
      if(!i){
	for(int k=1;k*frower[j][0]<51;k++){
	  dp[k*frower[j][0]][j] = min(dp[k*frower[j][0]][j],frower[j][1]*k);
	}
      }
      else{
	if(dp[i][j-1]){
	  for(int k=0;i+k*frower[j][0]<51;k++){
	    dp[i+k*frower[j][0]][j] = min(dp[i+k*frower[j][0]][j],dp[i][j-1]+frower[j][1]*k);
	  }
	}
      }
    }
  }
  int n;
  while(cin>>n,n){
    for(int i=n/100; i<51; i++){
      if(dp[i][6]){cout <<dp[i][6]<<endl;break;}
    }
  }
  return 0;
}