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>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define SZ(n)  (int)n.size()
#define dump(x) cerr<<#x<<" = "<<(x)<<endl;
#define debug(x)cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define MP make_pair
#define PB push_back
	
	int n;
	int dfs(int a,int b,int c){
		//cout<<a<<" "<<b<<" "<<c<<endl;
		if(a*200+b*300+c*500>n)return 1<<20;
		
		if(a*200+b*300+c*500==n){
			int ret=0;
			while(a>=5)a-=5,ret+=(380*5)*0.8;
			ret+=a*380;
			
			while(b>=4)b-=4,ret+=(550*4)*0.85;
			ret+=b*550;
			
			while(c>=3)c-=3,ret+=(850*3)*0.88;
			ret+=c*850;
			
			return ret;
		}
		
		int ret=1<<20;
	ret=min( ret,dfs(a+1,b,c) );
	ret=min( ret,dfs(a,b+1,c) );
	ret=min( ret,dfs(a,b,c+1) );
	
	return ret;
	}


	int main(){
	while(cin>>n,n){
	cout<<dfs(0,0,0)<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	int w[6] = {2,10,3,12,5,15}, v[6] = {380,380*5*0.8,550,550*4*0.85,850,850*3*0.88};
	int N;
	while(cin>>N,N){
		N /= 100;
		int dp[51]; fill_n(dp,51,INT_MAX/2); dp[0] = 0;
		for(int i=0;i<N;i++){
			for(int j=0;j<6;j++){
				if(i+w[j]<=N) dp[i+w[j]] = min(dp[i+w[j]],dp[i]+v[j]);
			}
		}
		printf("%d\n",dp[N]);
	}
}

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; shop[0]++ )
		{
			for ( shop[1] = 0; shop[1] * CONTENTS[1] <= n; shop[1]++ )
			{
				for ( shop[2] = 0; shop[2] * CONTENTS[2] <= n; 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>
using namespace std;
int main()
{
    int n,m,asum,bsum,csum,sum,a,b,c;
    while(cin >> n,n!=0){
        int mi = 1000010;
        for(int i=0;i<=n;i+=200){
            for(int j=0;j<=n-i;j+=300){
                int k=n-i-j;
                if(k%500 != 0) continue;
                asum = i/200;
                bsum = j/300;
                csum = k/500;
                sum = 380*(asum-asum%5)*80/100 + 380*(asum%5);
                sum += 550*(bsum-bsum%4)*85/100 + 550*(bsum%4);
                sum += 850*(csum-csum%3)*88/100 + 850*(csum%3);
                mi = min(mi,sum);
            }
        }
        cout << mi << 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+199)/200;i++){
			int a=i/5*5*380*80/100;
			a += i%5*380;
			for(int j=0;j<=(m-i*200+299)/300;j++){
				int b=j/4*4*550*85/100;
				b += j%4*550;
				int k=(m-i*200-j*300+499)/500,c;
				c=k/3*3*850*88/100;
				c += k%3*850;
				ans=min(ans,a+b+c);
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int main() {
	int n, m = 5000 * 500;
	cin >> n;
	if (n == 0){
		return 0;
	}
	for (int i = n / 500; i >= 0; i--) {
		for (int j = n / 300; j >= 0; j--) {
			for (int k = n / 200; k >= 0; k--) {
				int w = i * 500 + j * 300 + k * 200;
				if (w == n) {
					int p = (i / 3 * 3 * 0.88 + i % 3) * 850 + (j / 4 * 4 * 0.85 + j % 4) * 550 + (k / 5 * 5 * 0.8 + k % 5) * 380;
					if (p < m) {
						m = p;
					}
				}
			}
		}
	}
	cout << m << endl;
	return main();
}