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 <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 <cstdio>

int main(){
	int n, ans;
	while(scanf("%d", &n),n){
		ans = 100000000;
		for(int i = 0; i <= 25; i++){
			for(int j = 0; j <= 20; j++){
				for(int k = 0; k <= 10; k++){
					if(i*200+j*300+k*500==n){
						int tmp;
						tmp = i*380+j*550+k*850-(i/5)*5*380*20/100-(j/4)*4*550*15/100-(k/3)*850*3*12/100;
						if(ans > tmp) ans = tmp;
					}
				}
			}
		}
		printf("%d\n", ans);
	}
}

C++: #include<iostream>

using namespace std;

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

int main()
{
  for(int i = 0; i < 5001; i++)
    dp[i] = 10000000;
  dp[0] = 0;
  for(int j = 0; j < 6; j++)
  {
    for(int i = 0; i < 5001; i += 100)
    {
      if(i + item[j] > 5000)
        continue;
      dp[i + item[j]] = min(dp[i + item[j]], dp[i] + price[j]);
    }
  }
  while(true)
  {
    int n;
    cin >> n;
    if(!n)
      break;

    cout << dp[n] << endl;
  }
}

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

int main(){
  int n;

  while(cin>>n,n){
    int ans = INT_MAX;

    for(int i=0;i*200<=10*n;i++){
      int aw = i * 200;
      for(int j=0;aw+j*300<=10*n;j++){
        int bw = j * 300;
        for(int k=0;aw+bw+k*500<=10*n;k++){
          int cw = k * 500;
          if(aw+bw+cw < n) continue;

          int calA = (i % 5) * 380 + (i / 5) * 5 * 380 * 0.8;
          int calB = (j % 4) * 550 + (j / 4) * 4 * 550 * 0.85;
          int calC = (k % 3) * 850 + (k / 3) * 3 * 850 * 0.88;

          ans = min(ans,calA+calB+calC);
        }
      }
    }

    cout<<ans<<endl;
  }
}

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

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

int main(){
  while(true){
    int n;
    cin>>n;
    if(!n)break;
    int mnval = 1145141919;
    for(int a=0;a*200<=n;++a){
      for(int b=0;a*200+b*300<=n;++b){
        int _c = n - (a*200+b*300);
        if(_c%500!=0)continue;
        int c = _c/500;
        int val = 0;
        val += 380*5*4/5*(a/5);
        val += 380*(a%5);
        val += 550*4*17/20*(b/4);
        val += 550*(b%4);
        val += 850*3*22/25*(c/3);
        val += 850*(c%3);
        mnval = min(mnval,val);
      }
    }
    cout<<mnval<<endl;
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int

using namespace std;

int main()
{
	int n, A, B, C, a, b, c, price, lowprice;
	
	while(1){
		cin >> n;
		if(n == 0) break;

		lowprice = 10000000;

		A = n / 200;
		B = n / 300;
		C = n / 500;

		for(a=0; a<=A; a++){
			for(b=0; b<=B; b++){
				for(c=0; c<=C; c++){
					if(a*200 + b*300 + c*500 != n) continue;
					price = 0;

					price += ((a/5)*5*380*80)/100 + (a%5)*380;
					price += ((b/4)*4*550*85)/100 + (b%4)*550;
					price += ((c/3)*3*850*88)/100 + (c%3)*850;

					if(price < lowprice) lowprice = price;
				}
			}
		}

		cout << lowprice << endl;
	}

	return 0;
}

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

using namespace std;

int dp[55];
int weight[6] = { 2 ,3 ,5 ,10 ,12 ,15 };
int value[6] = { 380 ,550 ,850 ,1520 ,1870 ,2244 };

void compute(void){
  
  for( int i = 0 ; i < 100 ; i++ ) dp[i] = 99999;;
  dp[0] = 0;
  for( int i = 0 ; i < 6 ; i++ ){
    for( int j = 0 ; j + weight[i] < 55 ; j++ ){
	dp[j + weight[i]] = min( dp[j + weight[i]] , dp[j] + value[i] );
      // 値段はvalueの6種類のみだからづいじそのパターンで計算
    }
  }

}

int main(void){

  compute();

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int frower[6][2] = {{2,380},{3,550},{5,850},{10,1520},{12,1870},{15,2244}};
  int dp[51] = {0};
  for(int i=1; i<51; i++){dp[i] = 100000;}
  for(int i=0; i<51; i++){
    for(int j=0; j<7; j++){
      if(frower[j][0]<=i){
	dp[i] = min(dp[i],dp[i-frower[j][0]]+frower[j][1]);
      }
    }
  }
  int n;
  while(cin>>n,n){
    cout <<dp[n/100]<<endl;
  }
  return 0;
}