CF710E.Generate a String

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

zscoder 想要为某个编程竞赛题目生成一个输入文件。

他的输入是一个由 n 个字母 'a' 组成的字符串。他太懒了,不愿编写生成器,因此打算直接在文本编辑器中手动生成该输入。

初始时,文本编辑器为空。他在文本文件中插入或删除一个字母 'a' 需要 x 秒;复制整个文本文件内容并将其粘贴(即加倍)需要 y 秒。

zscoder 希望找出生成恰好包含 n 个字母 'a' 的输入文件所需的最短时间。请帮助他确定生成该输入所需的时间。

输入格式

The only line contains three integers n, x and y (1 ≤ n ≤ 107, 1 ≤ x, y ≤ 109) — the number of letters 'a' in the input file and the parameters from the problem statement.

唯一的一行包含三个整数 nn、xx 和 yy(1 ≤ n ≤ 1071 \leq n \leq 10^7,1 ≤ x, y ≤ 1091 \leq x, y \leq 10^9)——分别表示输入文件中字母 'a' 的个数以及题目描述中的参数。

输出格式

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

输出唯一的整数 tt —— 生成输入文件所需的最少时间。

输入输出样例

  • 输入#1

    8 1 1

    输出#1

    4
  • 输入#2

    8 1 10

    输出#2

    8

输入解题思路,AI测评打分。不知道怎么写?

首页