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 <cstdio>
#include <algorithm>

int gram;
int memo[30][30][30];

int solve(int A, int B, int C)
{
  if (memo[A][B][C] != -1)
    return memo[A][B][C];

  if (A*200 + B*300 + C*500 >= gram)
    return A*380 + B*550 + C*850 - (A/5*380 + B/4*330 + C/3*306);

  int ret =  std::min(solve(A+1, B, C), std::min(solve(A, B+1, C), solve(A, B, C+1)));
  return memo[A][B][C] = ret;
}

int main()
{
  while (~scanf("%d", &gram)) {
    if (gram == 0)
      break;
    for (int i = 0; i < 30; ++i) {
      for (int j = 0; j < 30; ++j) {
	for (int k = 0; k < 30; ++k)
	  memo[i][j][k] = -1;
      }
    }
    printf("%d\n", solve(0, 0, 0));
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(){
	int w[6]={2,3,5,10,12,15},m[6]={380,550,850,1520,1870,2244};
	int dp[51];
	rep(i,51)dp[i]=1000000000;
	dp[0]=0;
	for(int i=0;i<6;i++){
		for(int j=0;j<=50-w[i];j++){
			dp[j+w[i]]=min(dp[j+w[i]],dp[j]+m[i]);
		}
	}
	int n;
	while(cin>>n,n){
		cout<<dp[n/100]<<endl;
	}
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXI = 8, MAXJ = 60, INF = (1 << 28) - 1;

int w[] = {2, 3, 5, 10, 12, 15};
int v[] = {380, 550, 850, 1520, 1870 , 2244};
//int v[] = {380, 550, 850, 380*5 * 8 /10, 550*4*85/100, 850*3*88/100};
int dp[MAXI][MAXJ];

int main()
{
    memset(dp, INF, sizeof(dp));
    rep(j,MAXJ) dp[0][j] = INF;
    rep(i,MAXI) dp[i][0] = 0;


    REP(6)for(int j = 1;j<51;j++)
        dp[i+1][j] = min(dp[i][j], dp[i + 1][j - w[i]] + v[i]);

    int wei;
    while(cin >> wei && wei)cout << dp[6][wei / 100] << endl;

    
    return 0;
}

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

//?????????
#define AG 200
#define BG 300
#define CG 500
//?????????
#define AM 380
#define BM 550
#define CM 850
//??????????????????
#define AN 5
#define BN 4
#define CN 3
//??????????????????
#define AP 20
#define BP 15
#define BP 12

int main(){
	int g;
	int a,b,c;
	int total;
	int money,work;
	
	while(1){
	 cin>>g;
	 if(g==0){break;}
	 a=0;b=0;c=0;
	 total=0;money=0;
	 
	 for(c=0;c*CG<=g;c++){
	  for(b=0;c*CG+b*BG<=g;b++){
		total=c*CG+b*BG;
		a=(g-total)/200;
		total+=a*AG;
		if(total!=g){continue;}
		//???????¨????
		work=(a/AN)*AN*AM*AP/100+(a%AN)*AM + (b/BN)*BN*BM*BP/100+(b%BN)*BM + (c/CN)*CN*CM*CP/100+(c%CN)*CM;
		if(money<work){money=work;}
	  }
	 }
	 
	 cout<<money<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

const int INF = 1<<29;
 
int main()
{
    int n;
    int dp[51];
    int c[6] = {380, 550, 850, 1520, 1870, 2244};
    int d[6] = {2, 3, 5, 10, 12, 15};
 
    fill(dp, dp+51, INF);
    dp[0] = 0;
    for (int i = 0; i < 51; i++) {
	for (int j = 0; j < 6; j++) {
	    if (d[j] <= i) {
		dp[i] = min(dp[i], dp[i-d[j]]+c[j]);
	    }
	}
    }  
    while (cin >> n, n) {
	n /= 100;
	cout << dp[n] << endl;
    }
    return 0;
}

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

constexpr int INF = 1e9;

int main() {
    vector<int> w = {2, 3, 5}, v = {380, 550, 850};
    vector<int> dis = {20, 15, 12}, dis_cnt = {5, 4, 3};
    vector<vector<int>> dp(4, vector<int>(51, INF));
    dp[0][0] = 0;
    for(int i=0; i<3; ++i) {
        for(int j=50; j>=0; --j) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            for(int k=1; k<=(50-j+w[i]-1)/w[i]; ++k) {
                int next = min(50, j+w[i]*k);
                dp[i+1][next] = min(dp[i+1][next], dp[i][j]+(v[i]*dis_cnt[i])*(k/dis_cnt[i])*(100-dis[i])/100+v[i]*(k%dis_cnt[i]));
            }
        }
    }
    int n;
    while(cin >> n, n) {
        n /= 100;
        cout << dp[3][n] << endl;
    }
}

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

using namespace std;

int main(void) {
	while(1) {
		int minPrise = _INF, target_g;
		
		cin >> target_g;
		if(target_g == 0) { break; }
		for(int a = 0; a < 26; a++) {
			for(int b = 0; b < 17; b++) {
				for(int c = 0; c < 11; 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;
}

C++: #include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

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




int main(void){
	int n;
	while(scanf("%d", &n) &&n ){
		int dp[10000001] ={0};
		dp[0] = 0;
		
		for(int i = 1; ; i++){
			for(int j = 0; j < 6; j++){
				if(i-price[j] < 0)continue;
				dp[i] = max(dp[i-price[j]]+weight[j],dp[i]);
			}
			if(dp[i]>=n){
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

int ret;
int w;

void solve(int tmpw, int c){
  //cout << "tmpw = " << tmpw << endl;
  if(c >= ret) return;
  if(tmpw <= 0){
	ret = min(ret, c);
	return;
  }
  solve(tmpw-1500, c+850*3*0.88);
  solve(tmpw-1000, c+380*5*0.8);
  solve(tmpw-1200, c+550*4*0.85);
  solve(tmpw-500, c+850);
  solve(tmpw-300, c+550);
  solve(tmpw-200, c+380);

  return;
}

int main(void){
  while(cin >> w && w){
	ret = 1 << 30;
	solve(w,0);
	cout << ret << endl;
  }
}

C++: #include<iostream>

using namespace std;

int main() {
    while(1){
      int n;
      cin >> n;
      if(n==0) break;
      int min=10000000000000; 
     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;
    }