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 < 100; ++ a ) {
        for ( int b = 0; b < 100; ++ b ) {
            for ( int c = 0; c < 100; ++ 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;

int main() {
  int combi[100000][3] = {0},m=0;
  int input,price[100000] = {0},weight;
  int a,b,c,a1,b1,c1;

  while(cin >> input) {
    if(input == 0) break;
    for(int i=0;i<26;i++) {//generate combination of weight over input
      for(int j=0;j<17;j++) {
        for(int k=0;k<11;k++) {
          weight = 200*i + 300*j + 500*k;
          //cout << weight << " ";
          if(input == weight) {
            combi[m][0] = i;
            combi[m][1] = j;
            combi[m][2] = k;
            //cout << combi[m][0] << " " <<  combi[m][1] << " " << combi[m][2] << endl;
            m++;
          }
        }
      }
    }




    for(int i=0;i<m;i++) {//calculate price[i] from combi[i]
      a = combi[i][0] / 5;//sale
      a1 = combi[i][0] - a*5;//not sale
      b = combi[i][1] / 4;//sale
      b1 = combi[i][1] - b*4;//not sale
      c = combi[i][2] / 3;//sale
      c1 = combi[i][2] - c*3;//not sale
      price[i] = 1520 * a + 380 * a1 + 1870 * b + 550 * b1 + 2244 * c + 850 * c1;
      //      cout << price[i] << endl;
    }

    sort(price,price+m);

    cout << price[0] << endl;
    m=0;
    int price[100000] = {0};
  }
}

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);
      if(min>fee) min=fee;
	    }
	  }
	}
      }	
      cout << min <<endl;
     } 
   return 0;
    }

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

const int inf = 1<<20;

int main()
{
	int p[6][2] = 
	{
		{2  ,380},
		{3  ,550},
		{5  ,850},
		{2*5,380*5*0.80},
		{3*4,550*4*0.85},
		{5*3,850*3*0.88}
	};

	int dp[51] = {0};
	for(int i=1; i<51; i++) dp[i] = inf;

	int x;
	for(int j=0; j<6; j++)
	for(int i=0; i<51; i++)
	{
		x = p[j][0]+i;
		if(!(x<51)) break;

		if(dp[x]>dp[i]+p[j][1])
		{
			dp[x]=dp[i]+p[j][1];
		}
	}

	int g;
	while(cin >> g, g)
	{
		cout << dp[g/100] << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
 
using namespace std;
 
const int inf = 999999;
 
int func(int n)
{
  
  int r = inf, w;
 
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 17; j++){
      for(int k = 0; k <= 10; k++){
    w = i*200+j*300+k*500;
    if(n == w){
      r = min(r, (i/5)*1520 + (i%5)*380 + 1870*(j/4) + (j%4)*550 + 2244*(k/3) + (k%3)*850);
    } else if(n < w){
      break;
    }
      }
    }
  }

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int priceAtA(int n) {
    int bags = n / 200;
    int lp = bags % 5;
    return 380 * lp + (380 * (bags - lp) * 0.8);
}

int priceAtB(int n) {
    int bags = n / 300;
    int lp = bags % 4;
    return 550 * lp + (550 * (bags - lp) * 0.85);
}

int priceAtC(int n) {
    int bags = n / 500;
    int lp = bags % 3;
    return 850 * lp + (850 * (bags - lp) * 0.88);
}

void solve107(int n) {
    int price = 1e9;
    for (int i = 0; i <= n; i+=200) {
        for (int j = 0; i + j <= n; j+=300) {
            for (int k = 0; i + j + k <= n; k+=500) {
                if (i + j + k == n) {
                    price = min(price, priceAtA(i) + priceAtB(j) + priceAtC(k));
                }
            }
        }
    }
    cout << price << endl;
}

int main() {
    int n;
    while(cin >> n, n) {
        solve107(n);
    }
    return 0;
}

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

int n, ans;
int w[] = {200,300,500};
int p[] = {380,550,850};
int k[] = {5,4,3};
int d[] = {380,330,306};

void solve(int weight , int cost, vector<int> num){
	if( weight >= n ){
		ans = min( ans , cost );
		return;
	}
	for(int i=0 ; i < 3 ; i++ ){
		num[i]++;
		int cost_ = cost;
		if( num[i] % k[i] == 0 ){
			cost_ -= d[i];
		}
		solve( weight+w[i] , cost_+p[i] , num );
		num[i]--;
	}
}

int main(){
	while( cin >> n , n ){
		vector<int> num;
		for(int i=0 ; i < 3 ; i++ )
			num.push_back(0);
		ans = 1000000;
		solve( 0 , 0 , num );
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define MAXVALUE (1<<21)
vector<int> dp(5000+1,MAXVALUE);

void init(){
	int item[6] = {200,300,500,1000,1200,1500};
	int price[6]= {380,550,850,1520,1870,2244};
	
	dp[0]=0;

	for(int k=0;k<6;k++){
		for(int i=0;i+item[k]<=5000;i++){
			dp[i+item[k]] = min( dp[i+item[k]] , dp[i]+price[k] );
		}
	}
}

int main(){
	init();
	int n,mi;
	while(cin >> n && n){
		mi = dp[n];
		/*for(int i=n;i<=5000;i++){
			mi = min(dp[i],mi);
		}*/
		cout << mi << endl;
	}
}