問題一覧 > 通常問題

No.2744 Power! or +1

レベル : / AI推定難易度 : 1725 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 30
作問者 : Nzt3 / テスター : ponjuice kenken714 cho435 tassei903
お気に入りにしたユーザー ProblemId : 10839 / 自分の提出
問題文最終更新日: 2024-04-26 13:00:22
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.

  1. Replace $X$ with $X+1$. This costs $A$.
  2. Choose a positive integer $k$ and replace $X$ with $X^k$. This costs $B^k$.
  3. 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もしくは右上の雲マークをクリックしてアカウントを作成してください。