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 <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


int calc( int n, int value, int k, double p ) {
    return n / k * k * value * p + ( n % k ) * value;
}

int solve( int n ) {
    int res = INT_MAX;
    int W[3] = { 200, 300, 500 };
    int V[3] = { 380, 550, 850 };
    int K[3] = { 5, 4, 3 };
    double P[3] = { 0.8, 0.85, 0.88 };
    for ( int a = 0; a < 100; ++ a ) {
        for ( int b = 0; b < 100; ++ b ) {
            for ( int c = 0; c < 100; ++ c ) {
                int sumW = W[0] * a + W[1] * b + W[2] * c;
                if ( sumW != n ) continue;
                res = min( res,
                           calc( a, V[0], K[0], P[0] )
                           + calc( b, V[1], K[1], P[1] )
                           + calc( c, V[2], K[2], P[2] ));
            }
        }
    }
    return res;
}

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

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

int main() {
  int combi[100000][3] = {0},m=0;
  int input,price[100000] = {0},weight;
  int a,b,c,a1,b1,c1;

  while(cin >> input) {
    if(input == 0) break;
    for(int i=0;i<26;i++) {//generate combination of weight over input
      for(int j=0;j<17;j++) {
        for(int k=0;k<11;k++) {
          weight = 200*i + 300*j + 500*k;
          //cout << weight << " ";
          if(input == weight) {
            combi[m][0] = i;
            combi[m][1] = j;
            combi[m][2] = k;
            //cout << combi[m][0] << " " <<  combi[m][1] << " " << combi[m][2] << endl;
            m++;
          }
        }
      }
    }




    for(int i=0;i<m;i++) {//calculate price[i] from combi[i]
      a = combi[i][0] / 5;//sale
      a1 = combi[i][0] - a*5;//not sale
      b = combi[i][1] / 4;//sale
      b1 = combi[i][1] - b*4;//not sale
      c = combi[i][2] / 3;//sale
      c1 = combi[i][2] - c*3;//not sale
      price[i] = 1520 * a + 380 * a1 + 1870 * b + 550 * b1 + 2244 * c + 850 * c1;
      //      cout << price[i] << endl;
    }

    sort(price,price+m);

    cout << price[0] << endl;
    m=0;
    int price[100000] = {0};
  }
}

C++: #include<iostream>

using namespace std;

int main() {
    while(1){
      int n;
      cin >> n;
      if(n==0) break;
      int min = 1000000;
      int fee;
      for(int a=0;a<=n/200+1;a++){
	for(int b=0;b<=n/300+1;b++){
	  for(int c=0;c<=n/500+1;c++){
	    if(a*200+b*300+c*500==n){
	      fee=a*380+b*550+c*850;
	      if(a>=5) fee+=((a/5)*5*380)*0.8-((a/5)*5*380);
	      if(b>=4) fee+=((b/4)*4*550)*0.85-((b/4)*4*550);
	      if(c>=3) fee+=((c/3)*3*850)*0.88-((c/3)*3*850);
      if(min>fee) min=fee;
	    }
	  }
	}
      }	
      cout << min <<endl;
     } 
   return 0;
    }

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

const int inf = 1<<20;

int main()
{
	int p[6][2] = 
	{
		{2  ,380},
		{3  ,550},
		{5  ,850},
		{2*5,380*5*0.80},
		{3*4,550*4*0.85},
		{5*3,850*3*0.88}
	};

	int dp[51] = {0};
	for(int i=1; i<51; i++) dp[i] = inf;

	int x;
	for(int j=0; j<6; j++)
	for(int i=0; i<51; i++)
	{
		x = p[j][0]+i;
		if(!(x<51)) break;

		if(dp[x]>dp[i]+p[j][1])
		{
			dp[x]=dp[i]+p[j][1];
		}
	}

	int g;
	while(cin >> g, g)
	{
		cout << dp[g/100] << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
 
using namespace std;
 
const int inf = 999999;
 
int func(int n)
{
  
  int r = inf, w;
 
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 17; j++){
      for(int k = 0; k <= 10; k++){
    w = i*200+j*300+k*500;
    if(n == w){
      r = min(r, (i/5)*1520 + (i%5)*380 + 1870*(j/4) + (j%4)*550 + 2244*(k/3) + (k%3)*850);
    } else if(n < w){
      break;
    }
      }
    }
  }

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int priceAtA(int n) {
    int bags = n / 200;
    int lp = bags % 5;
    return 380 * lp + (380 * (bags - lp) * 0.8);
}

int priceAtB(int n) {
    int bags = n / 300;
    int lp = bags % 4;
    return 550 * lp + (550 * (bags - lp) * 0.85);
}

int priceAtC(int n) {
    int bags = n / 500;
    int lp = bags % 3;
    return 850 * lp + (850 * (bags - lp) * 0.88);
}

void solve107(int n) {
    int price = 1e9;
    for (int i = 0; i <= n; i+=200) {
        for (int j = 0; i + j <= n; j+=300) {
            for (int k = 0; i + j + k <= n; k+=500) {
                if (i + j + k == n) {
                    price = min(price, priceAtA(i) + priceAtB(j) + priceAtC(k));
                }
            }
        }
    }
    cout << price << endl;
}

int main() {
    int n;
    while(cin >> n, n) {
        solve107(n);
    }
    return 0;
}

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

int n, ans;
int w[] = {200,300,500};
int p[] = {380,550,850};
int k[] = {5,4,3};
int d[] = {380,330,306};

void solve(int weight , int cost, vector<int> num){
	if( weight >= n ){
		ans = min( ans , cost );
		return;
	}
	for(int i=0 ; i < 3 ; i++ ){
		num[i]++;
		int cost_ = cost;
		if( num[i] % k[i] == 0 ){
			cost_ -= d[i];
		}
		solve( weight+w[i] , cost_+p[i] , num );
		num[i]--;
	}
}

int main(){
	while( cin >> n , n ){
		vector<int> num;
		for(int i=0 ; i < 3 ; i++ )
			num.push_back(0);
		ans = 1000000;
		solve( 0 , 0 , num );
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define MAXVALUE (1<<21)
vector<int> dp(5000+1,MAXVALUE);

void init(){
	int item[6] = {200,300,500,1000,1200,1500};
	int price[6]= {380,550,850,1520,1870,2244};
	
	dp[0]=0;

	for(int k=0;k<6;k++){
		for(int i=0;i+item[k]<=5000;i++){
			dp[i+item[k]] = min( dp[i+item[k]] , dp[i]+price[k] );
		}
	}
}

int main(){
	init();
	int n,mi;
	while(cin >> n && n){
		mi = dp[n];
		/*for(int i=n;i<=5000;i++){
			mi = min(dp[i],mi);
		}*/
		cout << mi << endl;
	}
}