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 <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return b.second > a.second;
    }
    return a.first < b.first;
}

int arr[200010];
int a[200010], b[200010];

int GCD(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    return GCD(b, a % b);
}

int dp[55][30][30][30];

int rec(int sum, int cost, int a, int b, int c)
{
    if (sum == 0)
    {
        return cost;
    }
    if (sum < 0)
    {
        return INT_MAX;
    }
    if (dp[sum][a][b][c] != INT_MAX)
        return dp[sum][a][b][c];

    int res = INT_MAX;

    if ((a + 1) % 5 == 0)
    {
        res = min(res, rec(sum - 2, cost - 380 * 4 + 380 * 5 * 0.80, a + 1, b, c));
    }
    else
    {
        res = min(res, rec(sum - 2, cost + 380, a + 1, b, c));
    }

    if ((b + 1) % 4 == 0)
    {
        res = min(res, rec(sum - 3, cost - 550 * 3 + 550 * 4 * 0.85, a, b + 1, c));
    }
    else
    {
        res = min(res, rec(sum - 3, cost + 550, a, b + 1, c));
    }

    if ((c + 1) % 3 == 0)
    {
        res = min(res, rec(sum - 5, cost - 850 * 2 + 850 * 3 * 0.88, a, b, c + 1));
    }
    else
    {
        res = min(res, rec(sum - 5, cost + 850, a, b, c + 1));
    }

    return dp[sum][a][b][c] = min(dp[sum][a][b][c], res);
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    int n;
    while (cin >> n)
    {
        if (n == 0)
        {
            break;
        }

        for (int i = 0; i < 55; ++i)
        {
            for (int j = 0; j < 30; ++j)
            {
                for (int k = 0; k < 30; ++k)
                {
                    for (int l = 0; l < 30; ++l)
                    {
                        dp[i][j][k][l] = INT_MAX;
                    }
                }
            }
        }
        n /= 100;
        cout << rec(n, 0, 0, 0, 0) << endl;
    }
    return 0;
}

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

int main()
{
	/*1500g = 2244
	  1200g = 1870
	  1000g = 1520
	  500g  = 850
	  300g  = 550
	  200g  = 380  */

	int g , n;

	while (cin >> g)
	{
		if (g == 0) break;

		int p = 0;

		if (g/2200 >= 0)
		{
			n = g / 2200;
			p += 3390 * n;
			g -= 2200 * n;
		}

		if (g/1500 >= 0)
		{
			n = g / 1500;
			p += 2244 * n;
			g -= 1500 * n;
		}

		if (g / 1200 >= 0)
		{
			n = g / 1200;
			p += 1870 * n;
			g -= 1200 * n;
		}

		if (g / 1000 >= 0)
		{
			n = g / 1000;
			p += 1520 * n;
			g -= 1000 * n;
		}

		if (g / 500 >= 0)
		{
			n = g / 500;
			p += 850 * n;
			g -= 500 * n;
		}

		if (g / 300 >= 0)
		{
			n = g / 300;
			p += 550 * n;
			g -= 300 * n;
		}

		if (g / 200 >= 0)
		{
			n = g / 200;
			p += 380 * n;
			g -= 200 * n;
		}

		cout << p << endl;
	}

	return 0;
}

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

using namespace std;

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




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

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main( ){
  while(1){
    int n,sum=0,a,b,c,sa=0,min,a1=0,a2=0,a3=0;
  cin>>n;
  if(n==0)break;
  if(n>=1000){
    for(int i=0;i<=5;i++){
      for(int j=0;j<=5;j++){
        for(int q=0;q<=5;q++){
          sa=n-i*1500-j*1200-q*1000;
          if(i==0&&j==0&&q==0)min=sa;
          if(sa>=0&&sa!=100&&sa<min){
            min=sa;
            a1=i;
          a2=j;
          a3=q;
          }
        }
      }
    }
  }
  sum+=850*3*a1*0.88;
  sum+=550*4*a2*0.85;
  sum+=380*5*a3*0.8;
  n-=1500*a1;
  n-=1200*a2;
  n-=1000*a3;
  a=n/500;
  if(n%500==100)a--;
  sum+=850*a;
  n-=a*500;
  c=n/300;
  if(n%300==100)c--;
  sum+=550*c;
  n-=c*300;
  b=n/200;
  if(n%200==100)b--;
  sum+=380*b;
  cout<<sum<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
static const int INFTY = (1 << 30);
int n;

int calc() {

    int res = INFTY, r1, r2, r3;
    for (int i = 0; i <= n / 500 + 1; i++) {
        r1 = i / 3 * 3 * 850 * 88/ 100 + i % 3 * 850;
        for (int j = 0; j <= n / 300 + 1; j++) {
            r2 = j / 4 * 4 * 550 * 85 / 100 + j % 4 * 550;
            if (r1 + r2 > res) break;
            for (int k = 0; k <= n / 200 + 1; k++) {
                if (i * 500 + j * 300 + k * 200 != n) continue;
                r3 = k / 5 * 5 * 380 * 80 / 100 + k % 5 * 380;
                if (res < r1+r2+r3) break;
                res = min(res, r1+r2+r3);
            }
        }
    }

    return res;
}


/*int calc2(int qA, int qB, int qC) {
    if (qA * 200 + qB * 300 + qC * 500 >= n) {
        int res = qA / 5 * 1520 + qA % 5 * 380 + qB / 4 * 1870 + qB % 4 * 550 + qC / 3 * 2244 + qC % 3 * 850;
        return res;
    }
    return min(calc2(qA+1, qB, qC), min(calc2(qA, qB+1, qC), calc2(qA, qB, qC+1)));
}*/

int main()  {
    for (; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        cout << calc() << endl;
        //cout << calc2(0, 0, 0) << endl;

    }
    return 0;
}

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

int main()
{
  int n;
  while(1){
    int ans=1000000;
    cin>>n;
    if(n==0)break;
    for(int a=0; a<=50; a++){
      for(int b=0; b<=50; b++){
	for(int c=0; c<=50; c++){
	  int sum=(380*(5*(a/5)))*0.8+(a%5)*380;
	  sum+=(550*(4*(b/4)))*0.85+(b%4)*550;
	  sum+=(850*(3*(c/3)))*0.88+(c%3)*850;
	  if(a*200+b*300+c*500==n){
	    ans=min(ans, sum);
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}