Go: package main

import "fmt"

func main() {
	maxGram := 5000
	// store := map[int]int{
	// 	1500: 2244, // 500 * 3
	// 	1200: 1870, // 300 * 4
	// 	1000: 1520, // 200 * 5
	// 	500:  850,
	// 	300:  550,
	// 	200:  380,
	// }

	for {
		var gram int
		fmt.Scanf("%d", &gram)

		if gram == 0 {
			return
		}

		var minPrice int

		// (x * 200) + (y * 300) + (z * 500) == gram
		for x := 0; (x * 200) <= maxGram; x++ {
			for y := 0; (y * 300) <= maxGram; y++ {
				for z := 0; (z * 500) <= maxGram; z++ {
					if (x*200)+(y*300)+(z*500) == gram {
						price := 0
						price += (z / 3) * 2244
						price += (z % 3) * 850
						price += (y / 4) * 1870
						price += (y % 4) * 550
						price += (x / 5) * 1520
						price += (x % 5) * 380

						if price < minPrice || minPrice == 0 {
							minPrice = price
						}
					}
				}
			}
		}

		fmt.Println(minPrice)
	}
}

// 1 袋あたりの量			200g	300g	500g
// 1 袋の単価(定価)		380円	550円	850円
// 割引が適用される単位		5袋毎	4袋毎	3袋毎
// 割引率							20%引き	15%引き	12%引き

C++: #include<iostream>
#define INF 10000000
using namespace std;
int main(){
	int m[]={380,550,850,1520,1870,2244},dp[100010],
	w[]={2,3,5,10,12,15};
	for(int i=0;i<=100000;i++)
		dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<6;i++)
	for(int j=w[i];j<=100000;j++){
		//if(dp[j-w[i]]==INF)
		//dp[j]=min(m[i],dp[j]);
		//else
		dp[j]=min(dp[j],dp[j-w[i]]+m[i]);
	//	if(j==22)
		//cout<<i<<' '<<dp[j]<<endl;
	}
	//for(int i=0;i<=2500;i++)
	//cout<<' '<<dp[i]<<endl;
	int n;
	while(cin>>n,n){
		n/=100;
		int ans=INF;
		for(int i=n;i<=100000;i++){
			if(dp[i]!=INF)
			ans=min(ans,dp[i]);
		}
		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();

		for(int a=0; a<=25;a++){
			for(int b=0; b<=17;b++){
				for(int c=0; c<=10;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 <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <vector>

using namespace std;

int s=99999999;

void kakerukamosirenai(int total,int left,int a,int b,int c,int f){
	if(left>0){
		if(f==0){
			kakerukamosirenai(total+380,left-200,a+200,b,c,0);//a toru
			kakerukamosirenai(total,left,a,b,c,1);//a toranai
		}else if(f==1){
			kakerukamosirenai(total+550,left-300,a,b+300,c,1);//b toru
			kakerukamosirenai(total,left,a,b,c,2);//b toranai
		}else if(f==2){
			kakerukamosirenai(total+850,left-500,a,b,c+500,2);//c
		}
	}else if(left==0){
		int cnt=0;
		while(a>=1000){
			a-=1000;
//			total -= 380;
			cnt++;
		}
		total-=(1900*cnt)*20/100;
		cnt=0;

		while(b>=1200){
			b-=1200;
//			total -= 330;
			cnt++;
		}
		total-=(2200*cnt)*15/100;
		cnt=0;

		while(c>=1500){
			c-=1500;
//			total -= 306;
			cnt++;
		}
		total-=(2550*cnt)*12/100;

		if(s>total){
			s = total;
		}
	}else{
//		cout << "erratta" <<endl;
	}
}

int main(){

	vector<int> p;
	int n,c=0,a,t;

	while(1){
		cin >> n;
		p.push_back(n);
		if(p[c]==0)break;
		c++;
	}

	for(int i=0;i<c;i++){
		kakerukamosirenai(0,p[i],0,0,0,0);
		cout << s << endl;
		s = 999999999;
	}

	return 0;
}

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

typedef unsigned long long ull;

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

int main(){
    int n;
    while(cin >> n, n){
        int ans = 100000;
        rep(i, 26){
            rep(j, 21){
                rep(k, 11){
                    int cost = i*380 + j*550 + k*850 - (i/5)*5*0.2*380 - (j/4)*4*0.15*550 - (k/3)*3*0.12*850;
                    int weight = i*200 + j*300 + k*500;
                    if(weight == n) ans = min(ans, cost);
                }
            }
        }
        cout << ans << endl;
    }
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int CONTENTS[] = { 200, 300, 500 };
const int PRICE[] = { 380, 550, 850 };
const int UNIT[]= { 5, 4, 3 };
const double DISCOUNT[] = { 0.8, 0.85, 0.88 };

int main()
{
	while ( true )
	{
		int n;
		cin >> n;

		if ( n == 0 )
		{
			break;
		}

		int min = INT_MAX;
		int shop[] = { 0, 0, 0 };

		for ( shop[0] = 0; shop[0] * CONTENTS[0] <= n * 10; shop[0]++ )
		{
			for ( shop[1] = 0; shop[1] * CONTENTS[1] <= n * 10; shop[1]++ )
			{
				for ( shop[2] = 0; shop[2] * CONTENTS[2] <= n * 10; shop[2]++ )
				{
					int sum = 0;
					double price = 0;

					REP ( l, 0, 3 )
					{
						sum += CONTENTS[l] * shop[l];

						price += ( ( shop[l] / UNIT[l] ) * UNIT[l] ) * PRICE[l] * DISCOUNT[l];
						price += ( shop[l] % UNIT[l] ) * PRICE[l];
					}

					if ( n <= sum && price < min )
					{
						min = price;
					}
				}
			}
		}

		cout << min << endl;
	}

	return 0;
}

C++: #include <iostream>

int opts[6][2] = {{2, 380},   {3, 550},   {5, 850},
                  {10, 1520}, {12, 1870}, {15, 2244}};

int func(int qnt, int index, int subqnt, int subcost) {
    if (qnt == subqnt) return subcost;
    if (index < 0) return -1;
    int i = (qnt - subqnt) / opts[index][0];
    int min_cost = INT_MAX;
    while (i >= 0) {
        int res = func(qnt, index - 1, subqnt + opts[index][0] * i,
                       subcost + opts[index][1] * i);
        if (res > 0 && min_cost > res) min_cost = res;
        i--;
    }
    return min_cost;
}

int main() {
    int n;
    while (std::cin >> n && n > 0) {
        n /= 100;
        std::cout << func(n, 5, 0, 0) << std::endl;
    }
}