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<algorithm>
#define INF (1<<26)
using namespace std;

int n,ans;
int checkA(int);
int checkB(int);
int checkC(int);

int main(){
  while(cin>>n){
    if(n==0)break;

    ans=INF;
    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	for(int k=0;k<100;k++){

	  if(i*200+j*300+k*500>=n){
	    ans=min(ans,checkA(i)+checkB(j)+checkC(k));
	  }

	}
      }
    }    
    cout<<ans<<endl;
  }
  return 0;
}
int checkA(int cnt){
  int x = cnt - (cnt % 5), y = cnt % 5;
  return x*304 + y*380;
}

int checkB(int cnt){
  int x = cnt - (cnt % 4), y = cnt % 4;
  x/=4;
  return x*1870 + y*550;
}

int checkC(int cnt){
  int x = cnt - (cnt % 3), y = cnt % 3;
  return x*748 + y*850;
}

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<bits/stdc++.h>
using namespace std;

int main(void){
    double dp[50101];
    fill(dp, dp+5001, 1<<29);
    dp[0]=0;
    for(int i=200; i<=5000; i++){
        dp[i]=dp[i-200]+380;
        if(i>=300)  dp[i]=min(dp[i], dp[i-300]+550);
        if(i>=500)  dp[i]=min(dp[i], dp[i-500]+850);
        if(i>=1000) dp[i]=min(dp[i], dp[i-1000]+380*5*0.8);
        if(i>=1200) dp[i]=min(dp[i], dp[i-1200]+550*4*0.85);
        if(i>=1500) dp[i]=min(dp[i], dp[i-1500]+850*3*0.88);
    }
    
    while(true){
        int num;
        cin >> num;
        if(num==0) break;
        cout << dp[num] << "\n";
    }
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;
int n, ret;
int main() {
    while(true) {
        scanf("%d", &n);
        if(n == 0) break;
        ret = 999999999;
        for(int a = 0; a <= 13; a++) {
            for(int b = 0; b <= 9; b++) {
                for(int c = 0; c <= 5; c++) {
                    int value = a * 200 + b * 300 + c * 500;
                    if(n == value) {
                        ret = min(ret, (a / 5) * 1520 + (a % 5) * 380 + (b / 4) * 1870 * (b % 4) * 550 + (c / 3) * 2244 + (c % 3) * 850);
                    }
                }
            }
        }
        printf("%d\n", ret);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
	int g[6] = {2,3,5,10,12,15};
	int p[6] = {380,550,850,1520,1870,2244};
	int dp[66];
	for (int &i : dp) i = 10e6;
	dp[0] = 0;
	for (int i=0; i<6; ++i) {
		for (int j=0; j<51; ++j) {
			int k = j+g[i];
			if (dp[j]!=10e6) {
				dp[k] = min(dp[k], dp[j]+p[i]);
			}
		}
	}
	int n;
	while (cin >> n && n!=0) {
		cout << dp[n/100] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#define INF (1<<26)
using namespace std;

int n,ans;
int checkA(int);
int checkB(int);
int checkC(int);

int main(){
  while(cin>>n){
    if(n==0)break;

    ans=INF;

    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	for(int k=0;k<100;k++){
	  if(i==5&&j==0&&k==0)cout<<checkA(i)<<' '<<checkB(j)<<' '<<checkC(k)<<endl;
	  if( i*200+j*300+k*500 == n){
	    ans=min(ans,checkA(i)+checkB(j)+checkC(k));
	  }

	}
      }
    }    
    cout<<ans<<endl;
  }
  return 0;
}
int checkA(int cnt){

  int x = cnt - (cnt % 5), y = cnt % 5;
  return x*304 + y*380;
}

int checkB(int cnt){

  int x = cnt - (cnt % 4), y = cnt % 4;
  x/=4;
  return x*1870 + y*550;
}

int checkC(int cnt){

  int x = cnt - (cnt % 3), y = cnt % 3;
  return x*748 + y*850;
}

C++: #include <iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
    int n,sum,p,sump;
    while(1){
        sum=0;
        p=0;
        sump=0;
        cin>>n;
        p=n;
        if(n==0)break;
        for(int i=0;i<2;++i){
            if(i==0){
                if(n/1200>0){
                    sum+=n/1200*550*4*0.85;
                    n-=(n/1200)*1200;
                }
                if(n/1000>0){
                    sum+=n/1000*380*5*0.8;
                    n-=(n/1000)*1000;
                    }
                }
            else{
                if(p/1500>0){
                    sump+=p/1500*850*3*0.83;
                    p-=(p/1500)*1500;
                }
            }
        }
        sum=max(sump,sum);
        if(sum==sump&&sum!=0){
            n=p;
        }
        if(n>=500){
            sum+=n/500*850;
            n-=(n/500)*500;
        }
        if(n>=300){
            sum+=n/300*550;
            n-=(n/300)*300;
        }
        if(n>=200){
            sum+=n/200*380;
            n-=(n/200)*200;
        }
        cout<<sum<<endl;
        
    }
    
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int frower[7][2] = {{0,0},{200,380},{300,550},{500,850},{1000,1520},{1200,1870},{1500,2244}};
  int dp[6000][7] = {0};
  for(int i=0; i<6000; i+=100){
    for(int j=1; j<7; j++){
      if(!i){
	for(int k=1;k*frower[j][0]<6000;k++){
	  if(!dp[k*frower[j][0]][j]){dp[k*frower[j][0]][j] = frower[j][1]*k;}
	  else{dp[k*frower[j][0]][j] = min(dp[k*frower[j][0]][j],frower[j][1]*k);}
	}
      }
      else{
	if(dp[i][j-1]){
	  for(int k=0;i+k*frower[j][0]<6000;k++){
	    if(!dp[i+k*frower[j][0]][j]){dp[i+k*frower[j][0]][j] = dp[i][j-1]+frower[j][1]*k;}
	    else{dp[i+k*frower[j][0]][j] = min(dp[i+k*frower[j][0]][j],dp[i][j-1]+frower[j][1]*k);}
	  }
	}
      }
    }
  }
  int n;
  while(cin>>n,n){
    for(int i=n; i<6000; i++){
      if(dp[i][6]){cout <<dp[i][6]<<endl;break;}
    }
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	std::ios_base::sync_with_stdio();

	int n;
	int dp[51];
	bool f;

	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0;i<51;i++) dp[i]=-1;
		dp[n/100]=0;
		f=true;
		while(f){
			f=false;
			for(int i=n/100;i>=0;i--){
				if(dp[i]!=-1){
					/*A5*/
					if(i>=10){
						if(dp[i-10]==-1||dp[i-10]>dp[i]+(380*5)*0.8){
							f=true;
							dp[i-10]=dp[i]+(380*5)*0.8;
						}
					}
					/*B5*/
					if(i>=12){
						if(dp[i-12]==-1||dp[i-12]>dp[i]+(550*4)*0.85){
							f=true;
							dp[i-12]=dp[i]+(550*4)*0.85;
						}
					}
					/*C5*/
					if(i>=15){
						if(dp[i-15]==-1||dp[i-15]>dp[i]+(850*3)*0.88){
							f=true;
							dp[i-15]=dp[i]+(850*3)*0.88;
						}
					}
					/*A1*/
					if(i>=2){
						if(dp[i-2]==-1||dp[i-2]>dp[i]+380){
							f=true;
							dp[i-2]=dp[i]+380;
						}
					}
					/*B1*/
					if(i>=3){
						if(dp[i-3]==-1||dp[i-3]>dp[i]+550){
							f=true;
							dp[i-3]=dp[i]+550;
						}
					}
					/*C1*/
					if(i>=5){
						if(dp[i-5]==-1||dp[i-5]>dp[i]+850){
							f=true;
							dp[i-5]=dp[i]+850;
						}
					}
				}
			}
		}
		cout<<dp[0]<<endl;
	}
	return 0;
}