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++: #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/5)*5*0.80 + 380 * (n%5);
}

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

int buy_C(int n){
	return 850*(n/3)*3*0.88 + 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<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<string, int>P;

int main() {
	int n;
	while (cin >> n, n) {
		int Min = INT_MAX;
		rep(i, n / 200 + 1) {
			rep(j, n / 300 + 1) {
				rep(k, n / 500 + 1) {
					if (i * 200 + j * 300 + k * 500 == n) {
						Min = min(Min, 380 * i + 550 * j + 850 * k - i / 5 * 380 - j / 4 * 330 - k / 3 * 306);
					}
				}
			}
		}
		cout << Min << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<string>
#include<utility>
#define INF 2<<29
using namespace std;
	int n;
	double price [3] = { 850,550,380 };
	double discount[3] = { 0.88,0.85,0.8 };
	double  group[3] = { 3.0,4.0,5.0 };
	double gram[3] = { 500.0,300.0,200.0 };
	vector<int> dp(5001, INF);
	int memo;
	int ans = 0;
	int amount = 0;
int main() {
		for (int i = 0; i <= 10; ++i) {
			for (int j = 0; j <= 17; ++j) {
				for (int k = 0; k <= 25; ++k) {
					amount = i*gram[0] + j*gram[1] + k*gram[2];
					if (amount > 5000)break;
					int warihukuro[3] = { (int)(i / 3) * 3,(int)(j / 4) * 4,(int)(k / 5) * 5 };
					memo = warihukuro[0] * price[0] * discount[0] + (i - warihukuro[0])*price[0] +
						warihukuro[1] * price[1] * discount[1] + (j - warihukuro[1])*price[1] +
						warihukuro[2] * price[2] * discount[2] + (k - warihukuro[2])*price[2];
					//cout << amount << " " << memo << endl;
					dp[amount] = min(memo, dp[amount]);
				}
			}
		}
		while(cin>>n&&n)
		cout << dp[n] << endl;
	
	return 0;
}

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

int main(){
	int dp[51];
	int amo[6] = { 2, 3, 5, 10, 12, 15 };
	int pri[6] = { 380, 550, 850, 1520, 1870, 2244 };
	dp[0] = 0;
	for( int i=1; i<=50; i++ ){
		dp[i] = (1<<30);
	}
	for( int i=0; i<6; i++ ){
		for( int j=0; j+amo[i]<51; j++ ){
			dp[j+amo[i]] = min( dp[j+amo[i]], dp[j]+pri[i] );
		}
	}
	int n;
	while( cin >> n, n ){
		cout << dp[n/100] << endl;
	}
}

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

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] + 5; i >= 0; i--) {
		for (int j = n / soba[1][0] + 5; j >= 0; j--) {
			for (int k = n / soba[0][0] + 5; 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();
}

C++: #include <iostream>
using namespace std;
#define gram_a 200
#define gram_b 300
#define gram_c 500
#define yen_a 380
#define yen_b 550
#define yen_c 850
#define set_a 5
#define set_b 4
#define set_c 3
#define dis_a 0.8
#define dis_b 0.85
#define dis_c 0.88
/*
int main() {
	int n,a, b, c;
	a = 0;
	b = 0;
	c = 0;
	while (1) {
		cout << "a = " << a << " b = " << b << " c = "<<c << endl;
		cout << "g = " << gram_a * a + gram_b * b + gram_c * c << endl;
		cout <<"y = "<< set_a * ((int)(a / set_a))*yen_a*dis_a + (a%set_a)*yen_a +
			set_b * ((int)(b / set_b))*yen_b*dis_b + (b%set_b)*yen_b +
			set_c * ((int)(c / set_c))*yen_c*dis_c + (c%set_c)*yen_c
			<< endl;
		cin >> n;
		if (n == 1)
			c++;
		if (n == 2) {
			b++;
			c = 0;
		}
		if (n == 3) {
			a++;
			b = 0;
			c = 0;
		}
	}

}
*/

int main() {
	int n;
	while (cin >> n) {
		if (n == 0)
			break;
		int i, a = 0, b = 0, c = 0, min = 0, y, g;
		bool f=true, brk=false;
		for (a = 0;; a++) {
			for (b = 0;; b++) {
				for (c = 0;; c++) {
					brk = false;
					g = gram_a * a + gram_b * b + gram_c * c;
					if (n == g) {
						y = set_a*((int)(a / set_a))*yen_a*dis_a + (a%set_a)*yen_a +
							set_b*((int)(b / set_b))*yen_b*dis_b + (b%set_b)*yen_b +
							set_c*((int)(c / set_c))*yen_c*dis_c + (c%set_c)*yen_c;
						if (min > y || f) {
							min = y;
							f = false;
						}
						break;
					}
					if (n<g) {
						if (c == 0)
							brk = true;
						break;
					}
				}
				if (brk) {
					if (b > 0)
						brk = false;
					break;
				}
			}
			if (brk)
				break;
		}
		cout << min << endl;
	}
}

C++: #include <iostream>
using namespace std;
int f(int weight){
	int tw[] = {500,300,200},b[3],tp[] = {850,550,380},c[3],price = 0,tmp,d;
	double a[] = {0.88,0.85,0.80};
	for(int i = 0;i < 3;++i){
		d = (tw[i] * (i + 3));
		if((weight % d) == 0){
			return (int)((double)(weight / tw[i] * tp[i]) * a[i]);
		}
		tmp = weight;
		b[i] = tmp / (tw[i] * (i + 3)) * (i + 3);
		tmp -= (tw[i] * b[i]);
		price += (int)((double)(b[i] * tp[i]) * a[i]);
		for(int j = i + 1;j < 3;++j){
			b[j] = tmp / (tw[j] * (j + 3)) * (j + 3);
			tmp -= (tw[j] * b[j]);
			price += (int)((double)(b[j] * tp[j]) * a[j]);
			if(tmp < 0){
				price = 0;
				break;
			}
			else if(tmp == 0){
				return price;
			}
		}
		if((weight % tw[i]) == 0){
			d = weight / d * (i + 3);
			c[0] = (weight - (tw[i] * d)) / tw[i];
			return (int)((double)(d * tp[i]) * a[i]) + (c[0]* tp[i]);
		}
	}
	price = 0;
	for(int i = 0;i < 3;++i){
		b[i] = weight / tw[i];
		weight -= tw[i] * b[i];
		c[i] = b[i] / (i + 3) * (i + 3);
		b[i] -= c[i];
		price += (int)((double)(tp[i] * c[i]) * a[i]) + (tp[i] * b[i]);
	}
	return price;
}
int main(){
	int n;
	while(cin >> n && n){
		cout << f(n) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<climits>
using namespace std;
int main(){
  int n;    
  while(cin >> n,n){
    int ans=INT_MAX;
    for(int i=0;i<=25;i++){
      for(int j=0;j<=17;j++){
	for(int k=0;k<=10;k++){
	  if(i*200+j*300+k*500==n){
	    int temp;
	    temp=i*380+j*550+k*850;;
	    temp-=(i/5)*5*380*20/100+(j/4)*4*550*15/100+(k/3)*3*850*12/100;
	    if(ans>temp){
	      ans=temp;
	    }
	  }
	}
      }
    }
    cout << ans << endl;
  }
}