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;
}


typedef long long LL;

double calc( int n, double value, int k, double p ) {
    return value * (int)( n - n % k ) * p + ( n % k ) * value;
}

LL solve( int n ) {
    LL 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,
                           (LL)(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 <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int w;
	int dp[5001];
	fill_n(dp, 5001, INT_MAX);
	for (int i = 0; i < 25; i++)
		for (int j = 0; j < 17; j++)
			for (int k = 0; k < 10; k++) {
				int cost = (i*380) - (i/5*380) + (j*550) - (j/4*330) + (k*850) - (k/3*306);
				int total = 200 * i + 300 * j + 500 * k;
				if (total <= 5000)
					dp[total] = min(dp[total], cost);
			}
	while (cin >> w && w) {
		cout << dp[w] << endl;
	}

	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;
				c=k/5*5*380*80/100;
				c += k%5*380;
				ans=min(ans,a+b+c);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int buy_A(int n){
	return 5*380*0.80*(int)(n/5) + 380 * (n%5);
}

int buy_B(int n){
	return 4*550*0.85*(int)(n/4) + 550 * (n%4);
}

int buy_C(int n){
	return 3*850*0.88*(int)(n/3) + 850 * (n%3);
}

int main(){
	int W;
	while(~scanf("%d",&W)){
		if(W==0) break;
		W/=100;
		int res=numeric_limits<int>::max();


		//25,17,10
		for(int a=0; a<=30;a++){
			for(int b=0; b<=30;b++){
				for(int c=0; c<=30;c++){
					if(a*2+b*3+c*5 - W == 0){
						res = min(res,buy_A(a)+buy_B(b)+buy_C(c));
					}

				}
			}

		}

		cout << res << endl;

	}
}

C++: #include <iostream>

using namespace std;

int main(){
	int n;
	while(1){
		int min = 1000000;
		cin >> n;
		if(!n) break;
		for(int i=0;i <= n/500;i++){
			for(int j=0;j <= (n-i*500)/300;j++){
				int k,cost;
				if((n - i*500-j*300) % 200 != 0) continue;
				k = (n - i*500-j*300) / 200;
				cost = 748*((i/3)*3)*+850*(i % 3)+1870*(j/4)+550*(j % 4)+304*((k/5)*5)+380*(k % 5);
				if(min > cost) min = cost;
			}
		}
		
		cout << min << endl;
	}
	
	return 0;
}

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

int main(){
  int n;

  while(cin>>n,n){
    int ans = INT_MAX;
    int aMinus = 5 * 380 * 0.8;
    int bMinus = 4 * 550 * 0.85;
    int cMinus = 3 * 850 * 0.88;

    for(int i=(n+1000)/200;i>=0;i--){
      int aw = i * 200;
      for(int j=(n+1200)/300;j>=0;j--){
        int bw = j * 300;
        for(int k=(n+1500)/500;k>=0;k--){
          int cw = k * 500;
          if(aw+bw+cw < n) continue;

          int calA = (i % 5) * 380 + (i / 5) * aMinus;
          int calB = (j % 4) * 550 + (j / 4) * bMinus;
          int calC = (k % 3) * 850 + (k / 3) * cMinus;

          ans = min(ans,calA+calB+calC);
        }
      }
    }

    cout<<ans<<endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
int c;
int d[52];
int item[]={2,3,5,10,12,15};
int price[]={380,550,850,380*5*0.8,550*4*0.85,850*3*0.88};

void dp(int i){
  for(int j=0;j<6;j++){
    if(i+item[j]<51){
      d[i+item[j]]=min(d[i+item[j]],d[i]+price[j]);
      dp(i+item[j]);
    }
  }
  return;
}

int main(void){
  int n;
  for(int i=0;i<52;i++){
    d[i]=1000000;
  }
  d[0]=0;
  dp(0);
  while(cin>>n,n!=0){
    cout<<d[n/100]<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
const int gram[6] = {200,300,500,1000,1200,1500};
const int  val[6] = {380,550,850,1520,1870,2244};
int dp[7000];
void Init(){
  for(int i=0;i<5500;i++)dp[i] = 1<<30;
  // dp[200] = 380;dp[300] = 550;
  for(int i=0;i<6;i++)dp[gram[i]] = val[i];
  for(int i=0;i<6;i++){
    for(int j=400;(j-gram[i])<=5000;j+=100){
      if(j-gram[i] < 0)continue;
      dp[j] = min(dp[j],dp[j-gram[i]]+val[i]);
    }
  }
}

int main(){
  int n;
  Init();
  while(cin >> n && n){
    cout << dp[n] << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long n,w,p,pp[152],i,j,k;
for(i=0;i<=151;i++)pp[i]=27350;
for(i=0;i<=25;i++){
for(j=0;j<=17;j++){
for(k=0;k<=10;k++){
w=i*2+j*3+k*5;
p=(i/5*5)*380*0.8+(i%5)*380+(j/4*4)*550*0.85+(j%4)*550+(k/3*3)*850*0.88+(k%3)*850;
if(pp[w]>p)pp[w]=p;
}
}
}
while(cin>>n){
if(n==0)break;
cout<<pp[n/100]<<endl;
}
return 0;
}