No.2744 Power! or +1
問題文最終更新日: 2024-04-26 13:00:22
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
CPCTF 2024 : PPC
(順位表)
の他の問題:
Problem Statement
Initially, $X=1$. Find the minimum total cost to make $X$ a multiple of $N$ by performing the operations $0$ or more times.
In each operation, choose $1$ of the following $3$ operations and perform it.
- Replace $X$ with $X+1$. This costs $A$.
- Choose a positive integer $k$ and replace $X$ with $X^k$. This costs $B^k$.
- Replace $X$ with $X!$. This costs $C$.
Constraints
- $2 \le N,A,B,C \le 2 \times 10^5$
- All inputs are integers.
Input
The input is given from standard input in the following format.
$N$ $A$ $B$ $C$
Output
Output the answer.
Sample
Sample 1
Input
12 34 56 78
Output
180
Performing operation 1 $3$ times and operation 3 $1$ time results in $X=24$ at a cost of $180$.
Sample 2
Input
199999 123 456 789
Output
2562
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。