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 <algorithm>
#include <cstdlib>
using namespace std;

int main(){
	int weight;
	while(cin >> weight){
		if(weight == 0) break;
		int minimum_cost = 10000000;
		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;
}

C++: #include <iostream>
using namespace	std;
int main(){
  for(int n;cin>>n&&n;){
    int r=1e9;
    for(int c0=0;c0<=25;c0++)
      for(int c1=0;c1<=16;c1++)
        for(int c2=0;c2<=10;c2++)
          for(int c3=0;c3<=5;c3++)
            for(int c4=0;c4<=4;c4++)
              for(int c5=0;c5<=3;c5++)
                if(n==c0*200+c1*300+c2*500+c3*1000+c4*1200+c5*1500) r=min(r,c0*380+c1*550+c2*850+c3*1520+c4*1870+c5*2244);
    cout<<r<<endl;
  }
  return 0;
}

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

int main(){
  int g;
  int dp[3][51];

  
  for(int i=0;i<51;i++){
    int tmp = i/2;
    if(i>2*tmp)tmp++;
    dp[0][i] = (tmp/5) * 1520 + (tmp%5) * 380;
  }

  for(int i=0;i<51;i++){
    dp[1][i] = dp[0][i];
    for(int j=1;j<=i;j++){
      int tmp = j/3;
      if(j>3*tmp)tmp++;
      dp[1][i] = min(dp[1][i],dp[0][i-j] + (tmp/4)  * 1870 + (tmp%4) * 550);
    }
  }

  for(int i=0;i<51;i++){
    dp[2][i] = dp[1][i];
    for(int j=1;j<=i;j++){
      int tmp = j/5;
      if(j>5*tmp)tmp++;
      dp[2][i] = min(dp[2][i],dp[1][i-j] + (tmp/3) * 2244 + (tmp%3) * 850);
    }
  }
  //for(int i=0;i<51;i++)cout << i << ":" << dp[2][i] << endl;
  while(1){
    cin >> g;
    if(!g)break;

    cout << dp[2][g/100] << endl;
  }
}

C++: 5 8 105
8 5 105
1 2 24
99 98 24
12 13 26
1 22 23
1 13 201
13 16 112
2 24 50
1 82 61
1 84 125
1 99 999
99 1 999
98 99 999
1 99 11
99 1 12
0 0 0

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int cost(int a, int b, int c){
  int ret = 0;
  int aa = a % 5; a -= aa;
  int bb = b % 4; b -= bb;
  int cc = c % 3; c -= cc;
  ret += (int)(a * 380 * 4 / 5) + aa * 380;
  ret += (int)(b * 550 * 17/20) + bb * 550;
  ret += (int)(c * 850 * 22/25) + cc * 850;
  return ret;
}

int main(){
  int n;
  while(cin>>n, n){
    int ans = INT_MAX;
    n += 99;
    n /= 100;
    for(int i = 0; i < n + 25; i+=2){
      for(int j = 0; i + j < n + 25; j+=3){
        for(int k = 0; i + j + k < n + 25; k+=5){
          if(i + j + k == n)
            ans = min(ans, cost(i/2,j/3,k/5));
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<limits.h>
using namespace std;

int main()
{
	int ans[5001];
	for(int i = 500; i < 5100; i+=100)
	{
		ans[i]=INT_MAX;
		for(int j = 0; j <= 50; ++j)
		{
			for(int k = 0; k <= 50; ++k)
			{
				for(int l = 0; l <= 50 ; ++l)
				{
					if(j*200+k*300+l*500<i)
						continue;
					int tmp=0;
					tmp+=(j-j%5)*380*0.8+j%5*380;
					tmp+=(k-k%4)*550*0.85+k%4*550;
					tmp+=(l-l%3)*850*0.88+l%3*850;
					ans[i]=min(ans[i],tmp);
				}
			}
		}
	}
	int n;
	while(cin>>n,n) 
	{
		cout<<ans[n]<<endl;
	}
  return 0;
}

C++: #include <stdio.h>

int main() {
  int n;
  while (1) {
    if(scanf("%d", &n) == EOF)break;
    int ans = 1000000;
    for (int a = 0; a <= 50; a++) {
      for (int b = 0; b <= 50; b++) {
        for (int c = 0; c <= 50; c++) {
          int sum = (380 * a * 0.8) + (a % 5) * 380;
          sum += (550 * b * 0.85) + (b % 4) * 550;
          sum += (850 * c * 0.88) + (c % 3) * 850;
          if (a * 200 + b * 300 + c * 500 == n) {
            if (sum < ans)
              ans = sum;
          }
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

int main(){
	int m;
	while(cin>>m&&m){
		int ans=1<<30;
		for(int i=0;i<=(m+499)/500;i++){
			int a=i/3*3*850*88/100;
			a += i%3*850;
			for(int j=0;j<=max(0,(m-i*500+299)/300);j++){
				int b=j/4*4*550*85/100;
				b += j%4*550;
				int k=(m-i*500-j*300+199)/200,c=0;
				if(0<k){
					c=k/5*5*380*80/100;
					c += k%5*380;
				}
				ans=min(ans,a+b+c);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int f(int a,int b,int c){
	int res=0;
	res+=a/5*5*380*80/100+a%5*380;
	res+=b/4*4*550*85/100+b%4*550;
	res+=c/3*3*850*88/100+c%3*850;
	return res;
}

int main() {
	int n;
	while(n=in()){
		int res=1000000000;
		int a,b,c;
		for(a=0;a<=n/200+1;a++){
			for(b=0;b<=n/300+1;b++){
				for(c=0;c<=n/500+1;c++){
					if(a*200+b*300+c*500==n){
						chmin(res,f(a,b,c));
//cout<<a<<" "<<b<<" "<<c<<" "<<f(a,b,c)<<endl;
					}
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int dp[51];

int main(){
    int n;
    int store[6][2] = {
        {2,380},
        {3,550},
        {5,850},
        {10,1520},
        {12,1870},
        {15,2244}
    };
    while(cin >> n, n){
        rep(i, 51){
            dp[i] = 2 << 24;
        }
        dp[0] = 0;
        n /= 100;
        rep(i, n + 1){
            rep(j,6){
                if(i >= store[j][0]){
                    dp[i] = min(dp[i], dp[i - store[j][0]] + store[j][1]);
                }
            }
        }
        cout << dp[n] << endl;
    }
}