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>
using namespace std;
int m[50];
int main()
{
  int i,j,k,a,b,c,n;
  for(i=1;i<=50;i++){
    if((i%2) != 0) a = 10000;
    else a = ((i+1)/10) * 1520 + ((i+1)%10)/2 * 380;
    if((i%3) !=0) b = 10000;
    else b = ((i+2)/12) * 1870 + ((i+2)%12)/3 * 550;
    if((i%5) !=0) c = 10000;
    else c = ((i+4)/15) * 2240 + ((i+4)%15)/5 * 850;
    n = min(a,min(b,c));
    j = 2; k = i-2;
    while(j <= k){
      if(n > m[j] + m[k]) n = m[j] + m[k];
      j++; k--;
    }
    m[i] = n;
  }
  for(;;){
    cin >> n;
    if(n==0) break;
    cout << m[n/100] << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

int w[]={2,3,5,10,12,15};
int v[]={380,550,850,1520,1870,2244};

int dp[380*30+1];
void solve(){
	for(int i=0;i<6;i++){
		for(int j=v[i];j<=380*30;j++){
			dp[j]=max(dp[j],dp[j-v[i]]+w[i]);
		}
	}
}

main(){
	solve();
	int n;
	while(cin>>n){
		if(n==0)break;
		n/=100;
		int ans=0;
		for(;;++ans){
			if(dp[ans]>=n)break;
		}
		cout<<ans<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int price,gram,ans,Nowprice,num;
    while(cin>>gram&&gram!=0){
        ans=100000;
        if(gram%200==0){
            num=gram/200;
            ans=380*(num/5)*5*0.8+380*(num%5);
          //  cout/*<<380*(num/5)*5*0.8<<" "*/<</*380*/(num)/*<<" "<<ans*/<<endl;
        }
        if(gram%300==0){
            num=gram/300;
            Nowprice=550*(num/4)*4*0.85+550*(num%4);
            //cout<<550*(num/4)*4*0.15<<" "<<550*(num%4)<<" "<<Nowprice<<endl;
            if(Nowprice<ans)ans=Nowprice;
        }
        if(gram%500==0){
            num=gram/500;
            Nowprice=850*(num/3)*3*0.88+850*(num%3);
          //\  cout<<850*(num/3)*3*0.12<<" "<<850*(num%3)<<" "<<Nowprice<<endl;
            if(Nowprice<ans)ans=Nowprice;
        }
        cout<<ans<<endl;
    }
}

C++: #include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
//typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

struct Edge{
    int to,cost;
};
struct S{
    int n;
    char c;
};

map<int,int> prime_factor(int n){
    map<int,int> ret;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ret[i]++;
            n/=i;
        }
    }
    if(n!=1)ret[n]=1;
    return ret;
}

signed main (){
    int n;
    int q[]={200,300,500},m[]={380,550,850},nn[]={5,4,3},per[]={20,15,12};
    while(cin>>n){
        if(n==0)break;
        int ans=1e9;
        for(int i=0;i<=n;i+=200){
            for(int j=0;j<=n;j+=300){
                for(int k=0;k<=n;k+=500){
                    if(i+j+k>n)continue;
                    
                    if(i+j+k==n){
                        int in=i/q[0],jn=j/q[1],kn=k/q[2]; //袋数
                        int im=in/nn[0]*nn[0]*m[0]*(1-per[0]/100.0) + in%nn[0]*m[0];
                        int jm=jn/nn[1]*nn[1]*m[1]*(1-per[1]/100.0) + jn%nn[1]*m[1];
                        int km=kn/nn[2]*nn[2]*m[2]*(1-per[2]/100.0) + kn%nn[2]*m[2];
                        //cout<<i<<" "<<j<<" "<<k<<" "<<im+jm+km<<endl;
                        ans=min(ans,im+jm+km);
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
    

}


/*
001
010
011

*/