# 2021 年东华大学金马程序设计联赛

I. A Small Game
PDF 题面可用

This is a simple question. This is a simple question.This is a simple question.

You are given four integers $N , A , B$ and $C$.

Now you have a integer $K$ ($K = 0$ initially).

Each time you can choose one of the following operations:

1. Cost $A$ and gain $K+1$ ($K \to K+1$)
2. Cost $B$ and gain $K\times 2$ ($K \to K\times 2$)
3. Cost $C$ and gain $K-1$ ($K \to K-1$)

Find the minimun cost to get $N$.

### 输入格式

There are multiple test cases in this problem.$(T\leq 10^5+5)$

In each test case,there is only one line contains four integers $N(1\leq N\leq 10^9)$, $A(0\leq A\leq 10^9)$, $B(0\leq B\leq 10^9)$, $C(0\leq C\leq 10^9)$.

### 输出格式

For each test case print one line for the minimun cost to get $N$.

Input
1 0 0 0
10 1 10 1
10 1 0 10
10 10 0 1
Output
0
10
2
12

NaN