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++: #define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

ll n, ans;
void dfs(ll a, ll b, ll c)
{
	ll g = a * 200 + b * 300 + c * 500;
	if (g == n) {
		ll y = (a - a % 5) * 304 + a % 5 * 380 + (b - b % 4) / 4 * 1870 + b % 4 * 550 + (c - c % 3) * 748 + c % 3 * 850;
		ans = min(ans, y);
	} else if (g < n) {
		dfs(a + 1, b, c);
		dfs(a, b + 1, c);
		dfs(a, b, c + 1);
	}
}
signed main()
{
	while ((n = in()) != 0) {
		ans = INFLL;
		dfs(0, 0, 0);
		cout << ans << 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);
	//cout <<a<<"*"<<b<<"*"<<c<<"="<<fee<<endl;
      if(min>fee) min=fee;
	    }
	  }
	}
      }	
      cout << min <<endl;
     } 
   return 0;
    }

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

int target;
static const int amount[3] = {200, 300, 500};
static const int value[3] = {380, 550, 850};
static const int per[3] = {5, 4, 3};
static const double ratio[3] = {0.8, 0.85, 0.88};

int minv;

int getValue( int store, int n ){
    int discount = per[store] * (n/per[store]);
    int nondisc = n%per[store];
    return ((int)ceil(value[store]*ratio[store]*discount) + value[store]*nondisc);
}

int compute(){
    minv = INT_MAX;
    
    int sa, sb, sc;
    for ( int a = 0; a <= target/amount[0]; a++ ){
	for ( int b = 0; b <= target/amount[1]; b++ ){
	    for ( int c = 0; c <= target/amount[2]; c++ ){

		int total = a*amount[0] + b*amount[1] + c*amount[2];
		int value = getValue(0, a) + getValue(1, b) + getValue(2, c);

		if ( total == target ){
		    if ( minv > value ){
			minv = value;
			sa = a;
			sb = b;
			sc = c;
		    }
		}
	    }
	}
    }

    return minv;
}

int main(){
    while( cin >> target && target ) cout << compute() << 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 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 <= 60000; 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 <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

// 500 <= n <= 5000, n+=100
int main(){
    int n,a,b;

    while( cin >> n, n ){
        double ret = 99999999999.0;
        for(a=0; 200*a <= n; a++){
            for(b=0; 200*a + 300*b <= n; b++){
                if( (n - (200*a + 300*b)) % 500 != 0 ) continue;
                int c = (n - (200*a + 300*b)) / 500;
                double ac = (380*5*(int)(a/5))*0.8 + 380*(a%5);
                double bc = (550*4*(int)(b/4))*0.85 + 550*(b%4);
                double cc = (850*3*(int)(c/3))*0.88 + 850*(c%3);
                ret = min(ret, ac + bc + cc);
            }
        }
        printf("%d\n",(int)ret);
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int max,i,j,ans[10000],g[7];
	
	for(i=0;i<5001;i++)
	{
		ans[i]=10000000;
	}
	
	g[0]=200;g[1]=300;g[2]=500;g[3]=1000;g[4]=1200;g[5]=1500;
	ans[200]=380;ans[300]=550;ans[500]=850;ans[1000]=380*5*0.8;ans[1200]=550*4*0.85;ans[1500]=850*3*0.88;
	
	
	for(i=0;i<5001;i+=100)
	{
		if(ans[i]!=10000000)
		{
			for(j=0;j<6;j++)
			{
				if(i+g[j]>5001)
					break;
				if(ans[i+g[j]]>ans[i]+ans[g[j]])
				ans[i+g[j]]=ans[i]+ans[g[j]];
			}
		}
	}
	
	for(;;)
	{
		cin >> max;
		if(max==0)
			break;
		
		cout << ans[max] << endl;
	}
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 200000000
#define EQ(a,b) (abs((a)-(b))<EPS)
int w[6]={200,300,500,1000,1200,1500};
int price[6]={380,550,850,1520,1870,2244};
int main()
{
	int dp[6000];
	for(int i=0;i<6000;i++)
	{
		dp[i]=INF;
	}
	dp[0]=0;
	for(int k=0;k<6;k++)
	{
		for(int i=0;i+w[k]<=5000;i++)
		{
			dp[i+w[k]]=min(dp[i+w[k]],dp[i]+price[k]);
		}
	}
	while(1)
	{
		int n;
		cin >> n;
		if(n==0)break;
		cout << dp[n] << endl;
	}
	return 0;
}