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
const int INF=1<<28;
	/*int n;
	int dp[50][50][50];
	int ta[]={380,550,850},wa[]={5,4,3};
	
	int dfs(int a,int b,int c){
		//cout<<a<<" "<<b<<" "<<c<<endl;
		if(a*200+b*300+c*500>n)return dp[a][b][c]=INF;
		
		if(dp[a][b][c]!=INF)return dp[a][b][c];	
		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 dp[a][b][c]=ret;
		}
		
		int ret=INF;
	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 dp[a][b][c]=ret;
	}*/


	int main(){
	int n;
	while(cin>>n,n){
	int ans=1<<20;
		for(int i=0;i<=50;i++){
			for(int j=0;j<=50;j++){
				for(int k=0;k<=50;k++){
					int a=i,b=j,c=k,ret=0;
					if(a*200+b*300+c*500==n){
			
				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;
								ans=min(ans,ret);
				}

			}
		}
	}
	cout<<ans<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std ;

int table[5100] ;

void f(){
	for( int i=500 ; i<=5000 ; i += 100 ){
		
		for( int c=0 ; c*500<=i ; c++ ){
			for( int b=0 ; b*300+c*500<=i ; b++ ){
				for( int a=0 ; a*200+b*300+c*500<=i ; a++ ){
					
					int sum = 380*5*(a/5)*(1.00-0.2) + 380*(a%5) ;
					sum += 550*4*(b/4)*(1.00-0.15)+0.5 + 550*(b%4) ;
					sum += 850*3*(c/3)*(1.00-0.12) + 850*(c%3) ;
					
					if( sum!=0 && a*200+b*300+c*500 == i ) table[i] = min( table[i] , sum ) ;
				}
			}
		}
	}
}

main(){
	for( int i=500 ; i<=5000 ; i+=100 ) table[i] = 100000 ;
	f() ;
	
	int n ;
	while( cin >> n , n ){
		cout << table[n] << endl ;
	}
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
using namespace std;
#define INF (1<<29)
int N;
bool ok(int a,int b,int c){
  if(a*200+b*300+c*500==N) return true;
  return false;
}
int calc(int a,int b,int c){
  return a*380-(a/5)*380 + b*550-(b/4)*330 + c*850-(c/3)*306;
}
int main(){
  while(scanf("%d",&N),N){
    int res = INF;
    for(int a=0;a<251;a++){
      for(int b=0;b<200;b++){
	for(int c=0;c<101;c++){
	  if(ok(a,b,c))
	    res = min(res,calc(a,b,c));
	}
      }
    }
    printf("%d\n",res);
  }
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
/*
200 380
300 550
500 850
1000 380*5*0.8
1200 550*4*0.85
1500 850*3*0.88

*/
int main(){
	int n;
	int dp[110]={0};
	rep(i,110) dp[i]=1<<20;
	int d[7][2];
	d[0][0]=2;
	d[0][1]=380;

	d[1][0]=3;
	d[1][1]=550;

	d[2][0]=5;
	d[2][1]=850;

	d[3][0]=10;
	d[3][1]=380*5*0.8;

	d[4][0]=12;
	d[4][1]=550*4*0.85;

	d[5][0]=15;
	d[5][1]=850*3*0.88;

	d[6][0]=0;
	d[6][1]=0;
	rep(i,6){
		// cout<<d[i][0]<<" "<<d[i][1]<<endl;
		dp[d[i][0]]=d[i][1];
	}
	dp[0]=dp[1]=300000;
	rep(i,56){
		rep(j,7){
			dp[i+d[j][0]]=min(dp[i+d[j][0]],dp[i]+d[j][1]);
		}
	}
	rep(i,57){
		// cout<<dp[i]<<endl;
	}
	while(cin>>n,n){
		cout<<dp[n/100]<<endl;
	}
}

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

using namespace std;

const int inf = 999999;

int func(int n)
{
  double r = inf, v; 
  int s, t, u, w;

  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 16; j++){
      for(int k = 0; k <= 10; k++){
	w = i*200+j*300+k*500;
	if(n == w){
	  s = i/5;
	  t = j/4;
	  u = k/3;
	  v = 0.8*5*s*380 + (i-5*s)*380 + 0.85*4*t*550 + (j-4*t)*550 + 0.88*3*u*850 + (k-3*u)*850;
	  r = min(r, v);
	} else if(n < w){
	  break;
	}
      }
    }
  }

  return (int)r;
}

int main()
{
  int n;

  while(cin >> n && n){
    cout << func(n) << endl;
  }

  return 0;
}

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 = ceil(n / 200.);
    int lp = bags % 5;
    return 380 * lp + (380 * (bags - lp) * 0.8);
}

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

int priceAtC(int n) {
    int bags = ceil(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+=100) {
        for (int j = 0; j <= n; j+=100) {
            for (int k = 0; k <= n; k+=100) {
                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<algorithm>

using namespace std;
int weight[]={200,300,500,1000,1200,1500};
int money[]={380,550,850,380*4,550*4*0.85,850*3*0.88};

int check(int i,int sum)
{
  //cout<<i<<"  "<<sum<<endl;
  if(sum<0|| i>5)
    return 99999;
  if(sum==0)
    return 0;
  return min(check(i+1,sum),money[i]+check(i,sum-weight[i]));
}

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int ans=99999;
      cout<<check(0,n)<<endl;
    }
}

C++: #include <stdio.h>
#define MIN(a,b) ((a>b)? b:a)
#define INT_MAX (1<<22)

int dp[61];
int data[61];

int search(int remains){
  if(dp[remains]) return data[remains];

  if(remains == 0) return 0;
  if(remains == 1) return INT_MAX;

  int k=INT_MAX;

  if(remains >= 15) k = MIN(k, search(remains-15)+2244);
  if(remains >= 12) k = MIN(k, search(remains-12)+1870);
  if(remains >= 10) k = MIN(k, search(remains-10)+1520);
  if(remains >= 5) k = MIN(k, search(remains-5)+850);
  if(remains >= 3) k = MIN(k, search(remains-3)+550);
  if(remains >= 2) k = MIN(k, search(remains-2)+380);

  dp[remains] = 1;
  return data[remains] = k;
}


int main(){
  int i;
  for(i=0;i<=60;i++) dp[i] = 0, data[i] = 0;

  search(60);
  
  int m = INT_MAX;
  for(i=60;i>=0;i--) {
    if(dp[i]) {
      m = data[i] = MIN(data[i], m);
    }else {
      data[i] = m;
    }

  }

  int n;
  while(1){
    scanf("%d", &n);
    if(n==0) break;
    printf("%d\n", data[n/100]);
  }
}