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

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

int buy_C(int n){
	return (int)(850*(int)(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 <iostream>
#include <limits.h>
#include <vector>
using namespace std;

const int WEIGHT_MAX = 5000;

int u_weight[] = { 200, 300, 500, 1000, 1200, 1500 };
int u_price[] = { 380, 550, 850, 1520, 1870, 2244 };

int main()
{
	vector< int > dp( WEIGHT_MAX + 1, INT_MAX );
	dp[ 0 ] = 0;

	for( int i = 0; i < 6; ++i ){
		for( int j = 0; j + u_weight[ i ] <= WEIGHT_MAX; ++j ){
			dp[ j + u_weight[ i ] ] = min( dp[ j + u_weight[ i ] ], ( dp[ j ] + u_price[ i ] < 0 ? INT_MAX : dp[ j ] + u_price[ i ] ) );
		}
	}

	int weight;

	while( cin >> weight && weight ){
		cout << dp[ weight ] << endl;
	}

	return 0;
}

C++: #include<stdio.h>



int main(void){
	
	int a,b,c,i,j,k,sobako,kingaku[850]={0},sum,temp,count;
	int ahiki,a_amari,bhiki,b_amari,chiki,c_amari;
	int a_weight,b_weight,c_weight;
	
	while(1){
		
		count=0;
		sobako=0;
		a=380; //200g 5Ü20%ø«
		b=550; //300g 4Ü15%ø«
		c=850; //500g 3Ü12%ø«
		a_weight=200;	//êÜÌd³
		b_weight=300;
		c_weight=500;
		
		for(i=0;i<850;i++){
			kingaku[i]=0;
		}
		
		scanf("%d",&sobako);
		
		if(sobako==0){
			break;
		}

		for(i=0;i<50;i++){
			for(j=0;j<40;j++){
				for(k=0;k<30;k++){
					sum=a_weight*i+b_weight*j+c_weight*k;
					if(sum==sobako){
						
						ahiki=i/5;	//øªKp³êéÜÌÂ
						a_amari=i%5; //øKpOÌÜÌÂ
						
						bhiki=j/4;
						b_amari=j%4;
						
						chiki=k/3;
						c_amari=k%3;
						
						kingaku[count]=(5*ahiki*0.80+a_amari)*a+(4*bhiki*0.85+b_amari)*b+(3*chiki*0.88+c_amari)*c;
						
						count++;			
					}
				}
			}
		}

		/*for(i=0;i<count;i++){
			printf("kingaku[%d]=%d\n",i,kingaku[i]);
		}*/
		
		for(i=0;i<count-1;i++){
			for(j=(count-1);j>i;j--){
				if(kingaku[j-1]>kingaku[j] && kingaku[j]!=0 && kingaku[j-1]!=0){
					temp=kingaku[j-1];
					kingaku[j-1]=kingaku[j];
					kingaku[j]=temp;
					//printf("kingaku[%d]==%d\n",j,kingaku[j]);
				}
			}
		}
		
		/*for(i=0;i<count;i++){
			printf("kingaku[%d]=%d\n",i,kingaku[i]);
		}*/
			printf("%d",kingaku[0]);
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb push_back

using namespace std;

int price(int a, int b, int c) {
	return 380 * (a / 5 * 5) * 0.8 + 380 * (a % 5) +
			550 * (b / 4 * 4) * 0.85 + 550 * (b % 4) +
			850 * (c / 3 * 3) * 0.88 + 850 * (c % 3);
}

int main() {
	//freopen("0106.inp", "r", stdin);
	int n; cin >> n;
	while (n != 0) {
		int p = 100000;
		loop(c, 0, n / 500 + 1) {
			int p1 = n - 500 * c;
			loop(b, 0, p1 / 300 + 1) {
				int p2 = p1 - 300 * b;
				if ((p2 >= 0) && (p2 % 200 == 0)) {
					int a = p2 / 200;
					p = min(p, price(a, b, c));
					//cout << a << ' ' << b << ' ' << c << endl;
				}
			}
		}
		cout << p << endl;
		cin >> n;
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen

using namespace std;
const double INF = (double)(1 << 20);
double dp[3][5001];			// gツづ個値ツ段ツ、

int main()
{
//	cut here before submit 
//	freopen ("testcase.DB", "r", stdin );

	const int g[3] = { 200, 300, 500 };
	const int t[3] = { 380, 550, 850 };
	const int d[3] = { 5, 4, 3 };
	const int r[3] = { 80, 85, 88 };

	for (int i = 0; i <= 5000; i++ ){
		for (int j = 0; j < 3; j++ ){
			dp[j][i] = INF;
		} // end for
	} // end for
	for (int j = 0; j < 3; j++ )
		dp[j][0] = 0.;

	for (int j = 0; j < 3; j++ ){
		for (int i = g[j], k = 1; i <= 5000; i += g[j], k++ ){
			dp[j][i] = dp[j][i-g[j]] + (double)t[j];
			if (k % d[j] == 0 ){
				if (k/d[j] == 1 ){
					dp[j][i] *= (double)r[j];
					dp[j][i] /= 100.;
				}else{
					dp[j][i] = dp[j][d[j]*g[j]]*(double)k/d[j];
				} // end if
			} // end if 
		} // end for
	} // end for
	int n;
	while (cin >> n, n ){
		int res = min(dp[0][n], min (dp[1][n], dp[2][n] ) );
		cout << res << endl;
	} // end while
/*
	for (int i = 0; i < 3; i++ ){
//	int i = 0;
		for (int j = 0; j <= 5000; j++ ){
			if (dp[i][j] != INF ){
				cout << "i: " << i << " j: " << setw(4) << j << " price: " << dp[i][j] << endl;
			} // end if
		} // end for
	} // end for 
*/		
	return 0;
}

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

struct SobaDisc {
  int gram;   //< ???
  int price;  //< ??????
};

vector<int> memo(5000, 1 << 20);

SobaDisc ShopInfo[6]{
  { 200, 380 },
  { 300, 550 },
  { 500, 850 },
  { 1000,1520 },
  { 1200,1870 },
  { 1500,2244 },
};

inline int min(int a, int b) { return a < b ? a : b; }

// ?????\??????????????????
void MinMoney() {
  for (int i = 0; i < 6; i++) {
    int gram  = ShopInfo[i].gram;
    int price = ShopInfo[i].price;
    memo[0] = 0;
    for (int j = 0; j + gram < 5000; j+=100) {
      memo[j + gram] = min(memo[j + gram], memo[j] + price);
    }
  }
}

int main() {
  MinMoney();

  int input_gram;
  while (cin >> input_gram) {
    cout << memo[input_gram] << endl;
  }
}

C++: /*
	0106:Discounts of Buckwheat
*/
#include	<iostream>
#include	<cstdio>
#include	<cmath>
#define _INF 20000000

using namespace std;

int main(void) {
	int minPrise = _INF, target_g;
	
	while(1) {
		
		cin >> target_g;
		if(target_g == 0) { break; }
		for(int a = 0; a < 26; a++) {
			for(int b = 0; b < 26; b++) {
				for(int c = 0; c < 26; c++) {
					int buf = 0;
					
					if((200*a) + (300*b) + (500*c) != target_g) { continue; }
					buf += 380*(a-a%5)*0.80+380*(a%5);
					buf += 550*(b-b%4)*0.85+550*(b%4);
					buf += 850*(c-c%3)*0.88+850*(c%3);
					minPrise = min(minPrise, buf);
				}
			}
		}
		cout << minPrise << endl;
	}
	return 0;
}