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>

using namespace std;

int dp[10000000];

int main()
{
	for(;;){
		int n;		//d³
		int g[6] 	= {200, 300, 500, 1000, 1200, 1500};
		int kane[6] = {380, 550, 850, 1520, 1870, 2244};
		
		fill(dp,dp+1000000, 10000000);
		
		dp[0] = 0;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		//d³ÜÅ
		for(int i = 0; i <= n*2; i+=100){
			for(int j = 0; j < 6; j++){
				if(i-g[j] < 0){
					continue;
				}
				if(dp[i-g[j]]+kane[j] < dp[i]){
					dp[i] = dp[i-g[j]]+kane[j];
				}
			}
		} 
		 /*
		for(int i = 0; i <= n*2; i+= 100){
			
			for(int j = 1;; j++){
				if(dp[i] < dp[i+j*100]){
					break;
				}
				else{
					dp[i] = dp[i+j*100];
				//	cout <<"*" <<dp[i] << endl;
				}
			}
	//		cout << dp[i] << endl;
		}
		
		*/
		
		cout << dp[n] << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int dp[5001];
bool able[5001];

void init(){
	vector<int> item;
	item.push_back(200);
	item.push_back(300);
	item.push_back(500);
	item.push_back(1000);
	item.push_back(1200);
	item.push_back(1500);
	vector<int> price;
	price.push_back(380);
	price.push_back(550);
	price.push_back(850);
	price.push_back( 1520 );
	price.push_back( 1870 );
	price.push_back( 2244 );
	rep(i,5001)dp[i]=(1<<20);
	able[0]=true;
	dp[0]=0;
	for(int k=0;k<item.size();k++){	
		for(int i=0;i+item[k]<=5000;i++){
			able[i+item[k]] = able[i+item[k]] | able[i];
			if(able[i+item[k]]){
				dp[i+item[k]] = min( dp[i+item[k]] , dp[i]+price[k] );
			}
		}
	}
	return;
}

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

C++: #include <iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
    int n,sum,p,sump;
    while(1){
        sum=0;
        p=0;
        sump=0;
        cin>>n;
        p=n;
        if(n==0)break;
        for(int i=0;i<2;++i){
            if(i==0){
                if(n/1200>0){
                    sum+=n/1200*550*4*0.85;
                    n-=(n/1200)*1200;
                }
                if(n/1000>0){
                    sum+=n/1000*380*5*0.8;
                    n-=(n/1000)*1000;
                    }
                }
            else{
                if(n/1500>0){
                    sump+=p/1500*850*3*0.82;
                    p-=(p/1500)*1500;
                }
            }
        }
        sum=max(sump,sum);
        if(sum==sump&&sum!=0){
            n=p;
        }
        if(n>=500){
            sum+=n/500*850;
            n-=(n/500)*500;
        }
        if(n>=300){
            sum+=n/300*550;
            n-=(n/300)*300;
        }
        if(n>=200){
            sum+=n/200*380;
            n-=(n/200)*200;
        }
        cout<<sum<<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] = (int)(( (tmp/5) * 5 * 0.80 + (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)  * 34 * 55 + (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) * 3 * 44 * 17 + (tmp%3) * 850);
    }
  }

  while(1){
    cin >> g;
    if(!g)break;

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

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

int main()
{
	int kona,i;
	int money[51];
	money[0] = 0;
	int size[6] = {2,3,5,10,12,15};
	int cost[6] = {380,550,850,1520,1870,2244};
		
	for(i=1;i<51;i++) money[i] = INF;
	
	for(i=0;i<50;i++)
	{
		if( money[i] != INF)
		{
			for(int j=0;j<6;j++)
			{
				if( (i + size[j]) < 51)
				{
					if( money[i]+cost[j] < money[ i+size[j] ] )
					{
						money[ i+size[j] ] = money[i] + cost[j];
					}
				}
			}
		}
	}


while(cin>>kona,kona != 0)
{
cout<< money[kona/100] << endl;
}
	
}

C++: #include<iostream>
#include<algorithm>
#define INF (1<<26)
using namespace std;

int n,ans;
int checkA(int);
int checkB(int);
int checkC(int);

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

    ans=INF;
    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	for(int k=0;k<100;k++){
	  if(i*200+j*300+k*500>=n){
	    ans=min(ans,checkA(i)+checkB(j)+checkC(k));
	  }
	}
      }
    }    
    cout<<ans<<endl;
  }
  return 0;
}
int checkA(int cnt){
  int x = cnt - (cnt % 5), y = cnt % 5;
  return x*304 + y*380;
}

int checkB(int cnt){
  int x = cnt - (cnt % 4), y = cnt % 4;
  x/=4;
  return x*1870 + y*550;
}

int checkC(int cnt){
  int x = cnt - (cnt % 3), y = cnt % 3;
  return x*748 + y*850;
}

C++: #include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        
        int dp[10000];
        rep(i,10000)dp[i]=INF;
        dp[0]=0;
        
        for(int i=1;i<=n;i++){
            if(i-200>=0)
                dp[i] = min(dp[i],dp[i-200]+380);
            if(i-300>=0)
                dp[i] = min(dp[i],dp[i-300]+550);
            if(i-500>=0)
                dp[i] = min(dp[i],dp[i-500]+850);
            if(i-1000>=0)
                dp[i] = min(dp[i],dp[i-1000]+1520);
            if(i-1200>=0)
                dp[i] = min(dp[i],dp[i-1200]+1870);
            if(i-1500>=0)
                dp[i] = min(dp[i],dp[i-1500]+2244);
        }
        cout<<dp[n]<<endl;
    }
}

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

#define INF 1<<28

int dp[5001];

int cost(int w) {
    switch (w) {
        case 0: return 0;
        case 200: return 380;
        case 300: return 550;
        case 500: return 850;
        case 1000: return 1520;
        case 1200: return 1870;
        case 1500: return 2244;
    }
    if (w < 0) return INF;
    if (dp[w] != -1) {
        return dp[w];
    }
    vector<int> costs(6);
    costs[0] = cost(w-200) + 380;
    costs[1] = cost(w-300) + 550;
    costs[2] = cost(w-500) + 850;
    costs[3] = cost(w-1000) + 1520;
    costs[4] = cost(w-1200) + 1870;
    costs[5] = cost(w-1500) + 2244;
    int min_cost = *min_element(costs.begin(), costs.end());
    dp[w] = min_cost;
    return min_cost;
}

int main() {
    int w;
    memset(dp, -1, sizeof(dp));
    while (cin >> w, w != 0) {
        cout << cost(w) << endl;
    }
    return 0;
}