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 <cstdio>
#include <cctype>
#include <utility>
#include <climits>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

struct table {
	int t[51];
	constexpr table() : t() {
		int ma[] = {2, 3, 5, 10, 12, 15}, mb[] = {380, 550, 850, 1520, 1870, 2244};
		for (int i = 1; i < 51; i++)
			t[i] = INT_MAX / 2;
		for (int i = 0; i < 6; i++)
			for (int j = ma[i]; j < 51; j++)
				t[j] = min(t[j], t[j - ma[i]] + mb[i]);
	}
};

int main() {
	constexpr table t;
	for (int a; (a = in());)
		outl(t.t[a/100]);
}

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 380*(n-n%5) * 0.8 + 380 * (n%5);
}

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

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

int main(){

	int**** dp = new int***[25+1];
	for(int i=0;i<=25;i++){
		dp[i] = new int**[17+1];
		for(int j=0;j<=17;j++){
			dp[i][j] = new int*[10+1];
			for(int k=0;k<=10;k++){
				dp[i][j][k] = new int[50+1];
			}
		}
	}

	for(int i=0;i<=25;i++){
		for(int j=0;j<=17;j++){
			for(int k=0;k<=10;k++){
				for(int l=0;l<=50;l++){
					dp[i][j][k][l] = 10000000;
				}
			}
		}
	}

	dp[0][0][0][0] = 0;

	for(int a=0; a<=25;a++){
		for(int b=0; b<=17;b++){
			for(int c=0; c<=10;c++){
				for(int w=0; w<=50; w++){
					if(w - a*2 >= 0){
						dp[a][b][c][w] = min(dp[a][b][c][w],dp[0][b][c][w-a*2]+buy_A(a));
					}
					if(w - b*3 >= 0){
						dp[a][b][c][w] = min(dp[a][b][c][w],dp[a][0][c][w-b*3]+buy_B(b));
					}
					if(w - c*5 >= 0){
						dp[a][b][c][w] = min(dp[a][b][c][w],dp[a][b][0][w-c*5]+buy_C(c));
					}
				}
			}
		}
	}

	int W;
	while(~scanf("%d",&W)){
		if(W==0) break;
		W/=100;
		int res=10000000;
		for(int i=0;i<=25;i++){
			for(int j=0;j<=17;j++){
				for(int k=0;k<=10;k++){
					res=min(res,dp[i][j][k][W]);
				}
			}
		}
		cout << res << endl;
	}


}

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<=n+16;i++){
			if(dp[i]!=INF)
			ans=min(ans,dp[i]);
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

const int INF = 1<<30;
int pp[3][30];
int a[3] = {2, 3, 5};
int p[3] = {380, 550, 850};
int u[3] = {5, 4, 3};
int d[3] = {80, 85, 88};
int dp[3][51];

void set(){
    int i,j,k;
    for(i = 0; i < 3; i++){
        int price = 0;
        for(j = 0;j < 30; j++){
            if( j%u[i] == 0 ) price = p[i]*j*d[i]/100; 
            else price += p[i];
            pp[i][j] = price;
        }
    }
    for(i = 0; i < 3; i++){
        for(j = 0; j <= 50; j++){
            dp[i][j] = INF;
        }
    }
    for(i = 0; a[0]*i <= 50; i++){
        dp[0][ a[0]*i ] = pp[0][i];
    }
    for(i = 1; i < 3; i++){
        for(j = 0; j <= 50; j++){
            for(k = 0; j-a[i]*k >= 0;k++){
               dp[i][j] = min(dp[i][j], dp[i-1][j-a[i]*k]+pp[i][k]);
            }
        }
    }
}

int main(){
    int n;
    set();
    while(cin>>n,n) cout << dp[2][n/100] << endl;
    return 0;
}

C++: #include <iostream>

using namespace std;

int soba[][2] = {
	{200, 380},
	{300, 550},
	{500, 850}
};

int main() {
	int n, m = 5000 * 500;
	cin >> n;
	if (n == 0){
		return 0;
	}
	for (int i = n / soba[2][0] + 100; i >= 0; i--) {
		for (int j = n / soba[1][0] + 100; j >= 0; j--) {
			for (int k = n / soba[0][0] + 100; k >= 0; k--) {
				int w = i * soba[2][0] + j * soba[1][0] + k * soba[0][0];
				if (w == n) {
					int p = (i / 3 * 3 * soba[2][1] * 0.88) + (i % 3 * soba[2][1]) + (j / 4 * 4 * soba[1][1] * 0.85) + (j % 4 * soba[1][1]) + (k / 5 * 5 * soba[0][1] * 0.8) + (k % 5 * soba[0][1]);
					if (p < m) {
						m = p;
					}
				}
			}
		}
	}
	cout << m << endl;
	return main();
}