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>

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>

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<pair<int, int>> v = {{200,  380},
                                {1000, 1520},
                                {300,  550},
                                {1200, 1870},
                                {500,  850},
                                {1500, 2244}};
    vector<int> dp(5001, INT_MAX);
    dp[0] = 0;

    FOR(i, 0, dp.size()) {
        FOE(p, v) {
            if (dp[i] != INT_MAX and i + p.first < dp.size()) {
                dp[i + p.first] = min(dp[i + p.first], dp[i] + p.second);
            }
        }
    }

    while (true) {
        int n;
        cin >> n;
        if (n == 0) { break; }
        print(dp[n]);
    }

}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int s;
	int max_n = 26;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	std::cin.rdbuf(ifs.rdbuf());
#endif

	while(std::cin >> s){
		if(s == 0){ break; }
		int min_val = 1000000000;

		for(int a = 0; a < max_n; a++){
			if(200 * a > s){ break; }
			for(int b = 0; b < max_n; b++){
				if(200 * a + 300 * b > s){ 
					break;
				}
				for(int c = 0; c < max_n; c++){
					if(200 * a + 300 * b + 500 * c > s){
						break;
					}
					if(200 * a + 300 * b + 500 * c == s){
						int val = 380 * 0.8 * (a - a % 5) + 380 * (a % 5) +
							550 * 0.85 * (b - b % 4) + 550 * (b % 4) +
							850 * 0.88 * (c - c % 3) + 850 * (c % 3);
						min_val = std::min(min_val, val);
					}
				}
			}
		}
		
		std::cout << min_val << std::endl;
	}


#if INPUT_FROM_FILE
		//fclose(fp);
#endif
	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-a_ori;
  res += a_dis*380*0.80 + a_ori*380;
  
  int b_ori = b%4;
  int b_dis = b-b_ori;
  res += b_dis*550*0.85 + b_ori*550;
  
  int c_ori = c%3;
  int c_dis = c-c_ori;
  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++: #include<iostream>

using namespace std;

int main() {
    while(1){
      int n;
      cin >> n;
      if(n==0) break;
      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);
	    }
	  }
	}
      }	
      cout << fee <<endl;
     } 
   return 0;
    }

C++: #include <iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
    int n,sum,p,sump;
    while(1){
        sum=0;
        p=0;
        sump=0;
        cin>>n;
        p=n;
        if(n==0)break;
        for(int i=0;i<2;++i){
            if(i==0){
                if(n/1200>0){
                    sum+=n/1200*550*4*0.85;
                    n-=(n/1200)*1200;
                }
                if(n/1000>0){
                    sum+=n/1000*380*5*0.8;
                    n-=(n/1000)*1000;
                    }
                }
            else{
                if(p/1500>0){
                    sump+=p/1500*850*3*0.83;
                    p-=(p/1500)*1500;
                }
                if(p/1200>0){
                    sump+=p/1200*550*4*0.85;
                    p-=(p/1200)*1200;
                }
                if(p/1000>0){
                    sump+=p/1000*380*5*0.8;
                    p-=(p/1000)*1000;
                }
            }
        }
        sum=max(sump,sum);
        if(sum==sump&&sum!=0){
            n=p;
        }
        if(n>=500){
            sum+=n/500*850;
            n-=(n/500)*500;
        }
        if(n>=300){
            sum+=n/300*550;
            n-=(n/300)*300;
        }
        if(n>=200){
            sum+=n/200*380;
            n-=(n/200)*200;
        }
        cout<<sum<<endl;
        
    }
    return 0;
}

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

#define MAX_N 10000

int dp[4][10000], cnt, cnt2;
int v[3] = { 2,3,5 }, w[3] = { 380,550,850 }, x[3] = { 5,4,3 }, y[3] = { 20,15,12 };

int main() {
	memset(dp, 127, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < MAX_N; j++) {
			cnt = 0; cnt2 = 0;
			for (int k = j; k < MAX_N; k += v[i]) {
				dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + cnt);
				cnt += w[i];
				cnt2++;
				if (cnt2%x[i] == 0) {
					cnt -= (w[i] * x[i])*y[i] / 100;
				}
			}
		}
	}
	while (true) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		cout << dp[3][n / 100] << endl;
	}
	return 0;
}