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 <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


int calc( int n, int value, int k, double p ) {
    return n / k * k * value * p + ( n % k ) * value;
}

int solve( int n ) {
    int res = INT_MAX;
    int W[3] = { 200, 300, 500 };
    int V[3] = { 380, 550, 850 };
    int K[3] = { 5, 4, 3 };
    double P[3] = { 0.8, 0.85, 0.88 };
    for ( int a = 0; a < 30; ++ a ) {
        for ( int b = 0; b < 30; ++ b ) {
            for ( int c = 0; c < 30; ++ c ) {
                int sumW = W[0] * a + W[1] * b + W[2] * c;
                if ( sumW != n ) continue;
                res = min( res,
                           calc( a, V[0], K[0], P[0] )
                           + calc( b, V[1], K[1], P[1] )
                           + calc( c, V[2], K[2], P[2] ));
            }
        }
    }
    return res;
}

int main() {
    int n;
    while ( cin >> n && n ) {
        cout << solve( n ) << endl;
    }
    return 0;
}

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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int v;
const int m[] = {200, 300, 500, 1000, 1200, 1500};
const int p[] = {380, 550, 850, 1520, 1870, 2244};
const int INF = 10000000;

/*
  @ツ残ツづィツづ個重ツつウ
*/
int dfs(int w) {
  if (w <= 0) return 0;
  int res = INF;
  rep(i,6) {
    res = min(res, dfs(w-m[i]) + p[i]);
  }
  return res;
}

void solve() {
  cout<<dfs(v)<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>v, v) {
    solve();
  }
  return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

int weight[6] = {200,300,500,1000,1200,1500};
int price[6]  = {380,550,850,1520,1870,2244}; 




int main(void){
	int n;
	while(scanf("%d", &n) &&n ){
		int dp[2000001] ={0};
		dp[0] = 0;
		
		for(int i = 1; ; i++){
			for(int j = 0; j < 6; j++){
				if(i-price[j] < 0)continue;
				dp[i] = max(dp[i-price[j]]+weight[j],dp[i]);
			}
			if(dp[i]>=n){
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

int w[]={2,3,5,10,12,15};
int v[]={380,550,850,1520,1870,2244};

int dp[50+1];
void solve(){
	for(int i=0;i<51;i++){
		dp[i]=INT_MAX/3;
	}
	dp[0]=0;
	for(int i=0;i<6;i++){
		for(int j=w[i];j<=50;j++){
			dp[j]=min(dp[j],dp[j-w[i]]+v[i]);
		}
	}
}

main(){
	solve();
	int n;
	while(cin>>n){
		if(n==0)break;
		n/=100;
		cout<<dp[n]<<endl;
	}
}

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 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int ans[51];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w[6] = {2, 3, 5, 10, 12, 15};
    int v[6] = {380, 550, 850, 1520, 1870, 2244};
    fill(ans, ans+51, INF);
    rep(a, 26){
        rep(b, 17){
            rep(c, 11){
                rep(d, 6){
                    rep(e, 5){
                        rep(f, 4){
                            int weight = 0;
                            weight += w[0] * a;
                            weight += w[1] * b;
                            weight += w[2] * c;
                            weight += w[3] * d;
                            weight += w[4] * e;
                            weight += w[5] * f;
                            if (weight <= 50) {
                                int sum = 0;
                                sum += v[0] * a;
                                sum += v[1] * b;
                                sum += v[2] * c;
                                sum += v[3] * d;
                                sum += v[4] * e;
                                sum += v[5] * f;
                                ans[weight] = min(ans[weight], sum);
                            }
                        }
                    }
                }
            }
        }
    }
    int weight;
    cin >> weight;
    while (weight != 0) {
        weight /= 100;
        cout << ans[weight] << endl;
        cin >> weight;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int price,gram,ans,Nowprice,num;
    while(cin>>gram&&gram!=0){
        ans=100000;
        if(gram%200==0){
            num=gram/200;
            ans=380*(num/5)*5*0.8+380*(num%5);
           // cout<<380*(num/5)*5*0.8<<" "<<380*(num%5)<<" "<<ans<<endl;
        }
        if(gram%300==0){
            num=gram/300;
            Nowprice=550*(num/4)*4*0.75+550*(num%4);
            //cout<<550*(num/4)*4*0.15<<" "<<550*(num%4)<<" "<<Nowprice<<endl;
            if(Nowprice<ans)ans=Nowprice;
        }
        if(gram%500==0){
            num=gram/500;
            Nowprice=850*(num/3)*3*0.88+850*(num%3);
          //\  cout<<850*(num/3)*3*0.12<<" "<<850*(num%3)<<" "<<Nowprice<<endl;
            if(Nowprice<ans)ans=Nowprice;
        }
        cout<<ans<<endl;
    }
}

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

int main(){
	int weight;
	while(cin >> weight){
		if(weight == 0) break;
		int minimum_cost = INT_MAX;
		for(int i = 0; (i-1) * 200 < weight; i++){
			int w2 = weight - 200 * i;
			for(int j = 0; (j-1) * 300 < w2; j++){
				int w3 = w2 - 300 * j;
				int k = 0;
				while(k * 500 < w3) k++;
				int cost = (i / 5) * 1520 + (i % 5) * 380
					+ (j / 4) * 1870 + (j % 4) * 550
					+ (k / 3) * 2244 + (k % 3) * 850;
				minimum_cost = min(minimum_cost, cost);
			}
		}
		cout << minimum_cost << endl;
	}
	return 0;
}