Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const qA, qB, qC = 200, 300, 500
const pA, pB, pC = 380, 550, 850
const dA, dB, dC = 5, 4, 3

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		q, _ := strconv.Atoi(stdin.Text())
		if q == 0 {
			break
		}

		// A 0袋から始める
		curPrice, newPrice := 0, 0
		// B
		for a := 0; a <= int(q/qA); a++ {
			for b := 0; b <= int((q-qA*a)/qB); b++ {
				// 残り
				rem := q - qA*a - qB*b
				if rem == 0 || ((rem > 0) && ((rem % qC) == 0)) {
					// ちょうど買える
					newPrice = amount(a, b, int(rem/qC))
					if curPrice == 0 || newPrice < curPrice {
						// println(a, b, int(rem/qC), newPrice)
						curPrice = newPrice
					}
				}
			}
		}
		fmt.Println(curPrice)
	}
}

func amount(a, b, c int) int {
	tA := int(float64(int(a/dA)*dA*pA)*0.8) + (a%dA)*pA
	tB := int(float64(int(b/dB)*dB*pB)*0.85) + (b%dB)*pB
	tC := int(float64(int(c/dC)*dC*pC)*0.88) + (c%dC)*pC
	// println("amount:", a, b, c, tA, tB, tC, tA+tB+tC)
	return tA + tB + tC
}

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