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>
using namespace std;

int main() {
  int n;
  int a[3] = {2, 3, 5};
  int b[3] = {380, 550, 850};
  int c[3] = {5, 4, 3};
  int d[3] = {20, 15, 12};
  int e[3];
  int z[51] = {0};
  int f, g, h, s;

  for (int i=0; i<3; i++) {
    e[i] = b[i] * c[i] * (100 - d[i]) / 100;
  }

  for (int i=0; i<3; i++) {
    for (int j=0; j<=50; j++) {
      if (j && !z[j]) continue;
      int k=1;
      while (1) {
        f = j+k*a[i];
        if (f>50) break;
        g = k / c[i];
        h = k - g*c[i];
        s = z[j] + g*e[i] + h*b[i];
        if (!z[f] || s<z[f]) z[f] = s;
        k++;
      }
    }
  }

  for (int i=2; i<=50; i++) {
    for (int j=i-1; j>=1; j--) {
      if (z[j] && z[j]<=z[i]) break;
      z[j] = z[i];
    }
  }

  while (cin >> n && n) {
    cout << z[n/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{
						printf("%d %d\n",res2,cost3);
						cost3=cost2+k*850-(int)(k/3)*306;
						ans=min(ans,cost3);
					}
				}
			}
		}
		printf("%d\n",ans);
	}
}

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

C++: #include<bits/stdc++.h>
#define mk make_pair
using namespace std;
int sum;
set<pair<pair<int,int>,int> >s;
void dfs(int a,int b,int c,int n){
  if(s.count(mk(mk(a,b),c)))return;
  s.insert(mk(mk(a,b),c));
  if(n==0){
    int aa=0,bb=0,cc=0;
    if(a>=5)aa=a/5*1520;
    if(b>=4)bb=b/4*1870;
    if(c>=3)cc=c/3*2244;
    sum=min(sum,aa+bb+cc+a%5*380+b%4*550+c%3*850);
  }
  else{
    if(n-200>=0)dfs(a+1,b,c,n-200);
    if(n-300>=0)dfs(a,b+1,c,n-300);
    if(n-500>=0)dfs(a,b,c+1,n-500);
  }
}
int main(){
  int a;
  while(cin>>a){
    s.clear();
    sum=1e9;
    dfs(0,0,0,a);
    cout<<sum<<endl;
  }
}

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

using namespace std;

int find_answer(int quantity, int curr) {
  pair<int, int> prices[] = {
    make_pair(1500, 2244),
    make_pair(1200, 1870),
    make_pair(1000, 1520),
    make_pair(500, 850),
    make_pair(300, 550),
    make_pair(200, 380)
  };
  auto price = prices[curr];
  int div = quantity / price.first;
  int mod = quantity % price.first;
  if (mod == 0) { return price.second * div; }
  if (curr == 5 && mod == 100) { return 999999; }

  int best = 999999;
  for (int i = 0; i <= div; ++i) {
    int answer = price.second * i +
        find_answer(quantity - (price.first * i), curr + 1);
    best = min(best, answer);
  }
  return best;
}

int main() {
  while (true) {
    int quantity;
    scanf("%d", &quantity);
    if (quantity == 0) { break; }
    printf("%d\n", find_answer(quantity, 0));
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
 
using namespace std;
 
const int inf = 999999;
 
int func(int n)
{
  int r = inf, w;
 
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 17; j++){
      for(int k = 0; k <= 10; k++){
    w = i*200+j*300+k*500;
    if(n == w){
      r = min(r, (i/5)*1520 + (i%5)*380 + 1870*(j/4) + (j%4)*550 + 2244*(k/3) + (k%3)*850);
    } else if(n < w){
      break;
    }
      }
    }
  }
 
  return r;
}
 
int main()
{
  int n;
 
  while(cin >> n && n){
    cout << func(n) << 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 ans_m = INF;
int W[6] = {200, 300, 500, 1000, 1200, 1500};
int P[6] = {380, 550, 850, 1520, 1870, 2244}; 

void dfs (int k, int rest, int x) {
    if (rest == 0) {
        ans_m = min(ans_m, x);
        return;
    }
    if (k == 6 || rest < 0) {
        return;
    }
    for (int i = 0; i <= 25; i++) {
        if (rest - W[k] * i < 0) break;
        dfs(k + 1, rest - W[k] * i, x + P[k] * i);
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int weight;
    cin >> weight;
    while (weight != 0) {
        ans_m = INF;
        dfs(0, weight, 0);
        cout << ans_m << endl;
        cin >> weight;
    }

    return 0;
}