問題一覧 > 通常問題

No.1453 Helping Hand

レベル : / AI推定難易度 : 126 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 228
作問者 : wataso / テスター : shiomusubi496 MtSaka
お気に入りにしたユーザー ProblemId : 6110 / 自分の提出
問題文最終更新日: 2021-03-31 20:18:10
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
新入生プログラミングコンテスト 2021(夜の部) (順位表) の他の問題:

Problem Statement

Wataso is bad at calculations.
Wataso is planning to hold a party and wants to buy candies as gifts. He plans to give $A$ candies to each $1$ person who comes. He sent invitations to $B$ people, but since Wataso is not well liked, $C$ of them will not come.
The base price per $1$ candy is $D$ yen, but discounts are applied as follows.

  • The price of the $1$st candy is $D$ yen (that is, it is not discounted).
  • For any $i$ satisfying $2\leq i$, letting $X$ yen be the price of the $i-1$-th candy,
    • if the remainder of $i$ divided by $10$ is not $0$, the price of the $i$-th candy is $X$ yen;
    • if the remainder of $i$ divided by $10$ is $0$ and $E\leq X$, the price of the $i$-th candy is $X-E$ yen;
    • if the remainder of $i$ divided by $10$ is $0$ and $E > X$, the price of the $i$-th candy is $X$ yen.
On behalf of Wataso, who is bad at calculations, please write a program that finds the amount of money required to buy the necessary number of candies.

Note that in some cases, there may be candies that can be bought for free.

Input

$A$ $B$ $C$ $D$ $E$
  • $1 \leq A \leq 100$
  • $1 \leq C \leq B \leq100$
  • $1 \leq D \leq 1000$
  • $1 \leq E \leq 1000$
  • All inputs are integers.

Output

Output the amount of money required to buy the necessary number of candies. Print a newline at the end.

Sample

Sample 1
Input
5 5 5 80 10
Output
0

It seems he really is not well liked.

Sample 2
Input
1 98 1 10 20
Output
970

It is good that few people declined. But being stingy with the candies seems likely to make him even less well liked!

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。