303676: CF710E. Generate a String

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Generate a String

题意翻译

给定正整数 $n$, $x$, $y$,你要生成一个长度为 $n$ 的字符串,有两种操作: + 添一字符或删去一个原有字符,代价为 $x$; + 将已有字串复制粘贴一次(翻倍),代价为 $y$。 求最小代价。

题目描述

zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of $ n $ letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor. Initially, the text editor is empty. It takes him $ x $ seconds to insert or delete a letter 'a' from the text file and $ y $ seconds to copy the contents of the entire text file, and duplicate it. zscoder wants to find the minimum amount of time needed for him to create the input file of exactly $ n $ letters 'a'. Help him to determine the amount of time needed to generate the input.

输入输出格式

输入格式


The only line contains three integers $ n $ , $ x $ and $ y $ ( $ 1<=n<=10^{7} $ , $ 1<=x,y<=10^{9} $ ) — the number of letters 'a' in the input file and the parameters from the problem statement.

输出格式


Print the only integer $ t $ — the minimum amount of time needed to generate the input file.

输入输出样例

输入样例 #1

8 1 1

输出样例 #1

4

输入样例 #2

8 1 10

输出样例 #2

8

Input

题意翻译

给定正整数 $n$, $x$, $y$,你要生成一个长度为 $n$ 的字符串,有两种操作: + 添一字符或删去一个原有字符,代价为 $x$; + 将已有字串复制粘贴一次(翻倍),代价为 $y$。 求最小代价。

加入题单

上一题 下一题 算法标签: