Under construction

Still being built. Things may change

Wuzhangyuan

Time limit2sMemory limit1024 MB

Summary
Given X, K, and C, find the minimum total cost to send X supplies in attempts costing a+C each, when Sima Yi blocks up to K attempts to maximize the cost.
Level

Medium6 of 10

Topics
Dynamic programming, Game theory, Binary search
Solved
No attempts yet

Statement

In 234 CE, Zhuge Liang of Shu commits the full strength of the state to a final northern campaign. After three years of preparation, the expedition army numbers about 100,000, the second largest Shu northern force after the Battle of Yiling. Sima Yi of Wei hears the news and immediately moves to stop him. Hearing that Zhuge Liang will come through Ye Valley, Sima Yi moves to Meixian (眉縣). Then he watches to see whether Zhuge Liang heads to Wugong (武功) or Wuzhangyuan (五丈原).

"If Zhuge Liang is a bold man, he will surely leave Wugong and advance east along the mountains. If he goes west and climbs Wuzhangyuan, the entire army (諸軍) will be safe."

Zhuge Liang is cautious, so he directs his troops to Wuzhangyuan, and the Shu and Wei armies clash there.

Zhuge Liang of Shu and Sima Yi of Wei face each other at Wuzhangyuan. Zhuge Liang makes several supply runs to send a total of XX of supplies to the army in the field.

Zhuge Liang can attempt to send a positive integer aa of supplies in one attempt, and this costs a+Ca+C.

Sima Yi can block up to KK of Zhuge Liang's supply attempts. A blocked attempt costs Zhuge Liang only the expense, and the supplies are lost.

Zhuge Liang wants to send a total of XX of supplies at the minimum cost, while Sima Yi blocks attempts so that Zhuge Liang spends the maximum cost. Both strategists do their utmost to achieve their goals. Compute the minimum cost for Zhuge Liang to deliver all XX of supplies.

Input

The first line contains three positive integers XX, KK, and CC, separated by spaces.

XX is the target amount of supplies Zhuge Liang wants to send. (1≤X≤10 000)(1 \leq X \leq 10\,000)

KK is the maximum number of supply attempts Sima Yi can block. (1≤K≤300)(1 \leq K \leq 300)

CC is the cost Zhuge Liang pays for each supply attempt. Specifically, an attempt to send aa costs a+Ca+C. (1≤C≤109)(1 \leq C \leq 10^9)

Output

Print the minimum cost for Zhuge Liang to send all XX of supplies on the first line.

Examples2

  1. Example 1

    Input
    1 1 3
    
    Expected output
    8
    
  2. Example 2

    Input
    100 30 10
    
    Expected output
    743