Problem:
Discounts of Buckwheat

Aizu is famous for its buckwheat. There are many people who make buckwheat noodles by themselves.

One day, you went shopping to buy buckwheat flour. You can visit three shops, A, B and C. The amount in a bag and its unit price for each shop is determined by the follows table. Note that it is discounted when you buy buckwheat flour in several bags.

Shop A

Shop B

Shop C

Amount in a bag

200g

300g

500g

Unit price for a bag (nominal cost)

380 yen

550 yen

850 yen

Discounted units

per 5 bags

per 4 bags

per 3 bags

Discount rate

reduced by 20 %

reduced by 15 %

reduced by 12 %

For example, when you buy 12 bags of flour at shop A, the price is reduced by 20 % for 10 bags, but not for other 2 bags. So, the total amount shall be (380 × 10) × 0.8 + 380 × 2 = 3,800 yen.

Write a program which reads the amount of flour, and prints the lowest cost to buy them. Note that you should buy the flour of exactly the same amount as the given input.

Input

The input consists of multiple datasets. For each dataset, an integer a (500 ≤ a ≤ 5000, a is divisible by 100) which represents the amount of flour is given in a line.

The input ends with a line including a zero. Your program should not process for the terminal symbol. The number of datasets does not exceed 50.

Output

For each dataset, print an integer which represents the lowest cost.

Sample Input

500
2200
0

Output for the Sample Input

850
3390

Solution in JAVA (judge verdict: Accepted)

import java.io.*;

public class Main {
    static final int MAX_GRAM = 5001;
    static final int MAX_SHOP = 3;
    static final int INF = 10000000;

    public static void main(String[] args) throws IOException {
        BufferedReader br
        = new BufferedReader(new InputStreamReader(System.in));

        int[] gram = {200, 300, 500};
        int[] price = {380, 550, 850};
        double[] disc = {0.8, 0.85, 0.88};
        int[][] dp = new int[MAX_SHOP][MAX_GRAM];
        for (int i = 0; i < MAX_SHOP; i++) {
            for (int j = 0; j < MAX_GRAM; j++) {
                dp[i][j] = INF;
            }
        }
        
        dp[0][0] = dp[1][0] = dp[2][0] = 0;
        for (int j = 1; j <= 5000 / 200; j++) {
            int mod = j % 5;
            dp[0][200 * j] = (int)((380 * (j - mod)) * 0.8 + 380 * mod);
        }

        for (int j = 1; j <= 5000 / 300; j++) {
            int mod = j % 4;
            dp[1][300 * j] = (int)((550 * (j - mod)) * 0.85 + 550 * mod);
        }

        for (int j = 1; j < 5000 / 500; j++) {
            int mod = j % 3;
            dp[2][500 * j] = (int)((850 * (j - mod)) * 0.88 + 850 * mod);
        }

        for (int i = 0; i < MAX_SHOP; i++) {
            for (int j = 200; j <= MAX_GRAM; j += 100) {
                for (int k = 1; (k * gram[i]) <= j; k++) {
                    int diff = j - (k * gram[i]);
                    dp[2][j] = Math.min(dp[2][j], dp[2][diff] + dp[i][k * gram[i]]);
                }
            }
        }

        String line;
        while (true) {
            line = br.readLine();
            int g = Integer.parseInt(line);
            if (g == 0) break;
            System.out.println(dp[2][g]);
        }
    }
}