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 <stdio.h>

using namespace std;

int main() {
	int g,a,b,c,m,mg;
	while(cin >> g) {
		if (g==0) break;
		mg=9999999;
		for (a=0;a<26;a++) for (b=0;b<17;b++) for (c=0;c<51;c++) {
			if (a*200+b*300+c*500!=g) continue;
            m=(a/5)*1520+(a%5)*380+(b/4)*1870+(b%4)*550+(c/3)*2244+(c%3)*850;
			mg=(mg > m) ? m : mg;
		}
    cout << mg << endl;
	}
    return 0;
	}

C++: #include <iostream>

using namespace std;

int soba[][2] = {
	{200, 380},
	{300, 550},
	{500, 850}
};

int main() {
	int n, m = 5000 * 500;
	cin >> n;
	if (n == 0){
		return 0;
	}
	for (int i = n / soba[2][0]; i >= 0; i--) {
		for (int j = n / soba[1][0]; j >= 0; j--) {
			for (int k = n / soba[0][0]; k >= 0; k--) {
				int w = i * soba[2][0] + j * soba[1][0] + k * soba[0][0];
				if (w == n) {
					int p = (i / 3 * 3 * soba[2][1] * 0.88) + (i % 3 * soba[2][1]) + (j / 4 * 4 * soba[1][1] * 0.85) + (j % 4 * soba[1][1]) + (k / 5 * 5 * soba[0][1] * 0.8) + (k % 5 * soba[0][1]);
					if (p < m) {
						m = p;
					}
				}
			}
		}
	}
	cout << m << endl;
	return main();
}

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 ){
        int ret = 999999999;
        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;
                int ac = 1520*(a/5) + 380*(a%5);
                int bc = 1870*(b/4) + 550*(b%4);
                int cc = 2244*(c/3) + 850*(c%3);
                //printf("a=%d, b=%d, c=%d, sum=%d,  n=%d, ac=%10.4lf, bc=%10.4lf, cc=%10.4lf, sum=%lf\n",a,b,c,200*a+300*b+500*c,n,ac,bc,cc,ac+bc+cc);
                ret = min(ret, ac + bc + cc);
            }
        }
        printf("%d\n",(int)(ret));
    }
    return 0;
}

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

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

  for(int i=0;i<3;i++){
    for(int j=0;j<51;j++){
      v[i][j] = 10000;
      dp[i][j] = 10000;
    }
  }

  for(int i=0;i<51;i++){
    if(!(i%2)){
      tmp = i/2;
      dp[0][i] = (tmp/5) * 1520 + (tmp%5) * 380;
    }
    if(!(i%3)){
      tmp = i/3;
      v[1][i] = (tmp/4) * 1870 + (tmp%4) * 550;
    }
    if(!(i%5)){
      tmp = i/5;
      v[2][i] = (tmp/3) * 2244 + (tmp%3) * 850;
    }
  }

  for(int i=1;i<3;i++){
    for(int j=0;j<51;j++){
      for(int k=0;k<=j;k++)dp[i][j] = min(dp[i][j],dp[i-1][j-k] + v[i][k]);
    }
  }

  while(1){
    cin >> g;
    if(!g)break;
    cout << dp[2][g/100] << endl;
  }
}

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

int s[51];

void solve();

int main()
{
	int n;
	solve();
	while(cin >> n, n) {
		cout << s[n/100] << endl;
	}
}

void solve()
{
	 int q[6] = {2, 3, 5, 10, 12, 15}, v[6] = {380, 550, 850, 1520, 1870, 2244};
	 for(int i = 5; i <= 50; i++) {
		 s[i] = 1000000;
	 }
	 for(int i = 5; i <= 50; i++) {
		 for(int j = 0; j < 3; j++) {
			 int w = 0, sum = 0;
			 while(w < i) {
				 if(i >= q[j+3] && i >= w + q[j] * (5 - j)) {
					 sum += v[j+3];
					 w += q[j+3];
				 }
				 else {
					 sum += v[j];
					 w += q[j];
				 }
			 }
			 s[i] = min(s[i], sum);
		 }
	 }
}

C++: #include<stdio.h>



int main(void){
	
	int a,b,c,i,j,k,sobako,kingaku[850]={0},sum,temp,count;
	int ahiki,a_amari,bhiki,b_amari,chiki,c_amari;
	int a_weight,b_weight,c_weight;
	
	while(1){
		
		count=0;
		sobako=0;
		a=380; //200g 5Ü20%ø«
		b=550; //300g 4Ü15%ø«
		c=850; //500g 3Ü12%ø«
		a_weight=200;	//êÜÌd³
		b_weight=300;
		c_weight=500;
		
		for(i=0;i<850;i++){
			kingaku[i]=0;
		}
		
		scanf("%d",&sobako);
		
		if(sobako==0){
			break;
		}

		for(i=0;i<50;i++){
			for(j=0;j<40;j++){
				for(k=0;k<30;k++){
					sum=a_weight*i+b_weight*j+c_weight*k;
					if(sum==sobako){
						
						ahiki=i/5;	//øªKp³êéÜÌÂ
						a_amari=i%5; //øKpOÌÜÌÂ
						
						bhiki=j/4;
						b_amari=j%4;
						
						chiki=k/3;
						c_amari=k%3;
						
						kingaku[count]=(5*ahiki*0.80+a_amari)*a+(4*bhiki*0.85+b_amari)*b+(3*chiki*0.88+c_amari)*c;
						
						count++;			
					}
				}
			}
		}

		/*for(i=0;i<count;i++){
			printf("kingaku[%d]=%d\n",i,kingaku[i]);
		}*/
		
		for(i=0;i<count-1;i++){
			for(j=(count-1);j>i;j--){
				if(kingaku[j-1]>kingaku[j] && kingaku[j]!=0 && kingaku[j-1]!=0){
					temp=kingaku[j-1];
					kingaku[j-1]=kingaku[j];
					kingaku[j]=temp;
					//printf("kingaku[%d]==%d\n",j,kingaku[j]);
				}
			}
		}
		
		/*for(i=0;i<count;i++){
			printf("kingaku[%d]=%d\n",i,kingaku[i]);
		}*/
			printf("%d\n",kingaku[0]);
	}
	return 0;
}

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

#define INF 1000000007
#define min(a,b) (a>b?b:a)

int lst[6][2] = {
	{ 2, 380},
	{ 3, 550},
	{ 5, 850},
	{10, 1520},
	{12, 1870},
	{15, 2244}
};
#define M 50
int dp[M+1];

int main() {
	int n;
	for(int i=0; i<=M; ++i) dp[i] = INF;
	dp[0] = 0;
	for(int i=1; i<=M; ++i) {
		for(int j=0; j<6; ++j) {
			if(i>=lst[j][0]) dp[i] = min(dp[i], dp[i-lst[j][0]]+lst[j][1]);
		}
		//cout << dp[i] << endl;
	}
	while(cin >> n && n) cout << dp[n/100] << endl;
	return 0;
}

C++: #include <cstdio>

int price;
int weight;

int calc_price(int a, int b, int c) {
  return 
    ((a/5)*5) * 380 * 0.8 + (a%5)*380
    + ((b/4)*4) * 550 * 0.85 + (b%4)*550
    + ((c/3)*3) * 850 * 0.88 + (c%3)*850;
}

void solve(int a, int b, int c) {
  int w = a*200 + b*300 + c*500;
  if (weight == w) {
    if (price >= calc_price(a,b,c)) {
      price = calc_price(a,b,c);
    }
    return;
  } else if (weight < w) {
    return;
  } else {
    solve(a+1, b, c);
    solve(a, b+1, c);
    solve(a, b, c+1);
  } 
}

int main() {
  while(scanf("%d", &weight), weight) {
    price = 1000000000;
    solve(0,0,0);

    printf("%d\n", price);
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int quan;
	while(cin>>quan&&quan!=0){
		int minCost=100000000;
		for(int i = 0; i <= 25; i++){
			for(int j = 0; j <= 17; j++){
				for(int k = 0; k <= 10; k++){
					if(i*200+j*300+k*500==quan){
						int il=i%5;
						int jl=j%4;
						int kl=k%3;
						double sum=(i-il)*380*0.8+il*380;
						sum+=(j-jl)*550*0.85+jl*550;
						sum+=(k-kl)*850*0.88+kl*850;
						minCost=min(minCost,(int)(sum+0.99999999));
					}
				}
			}
		}
		cout<<minCost<<endl;
	}

	return 0;
}