No.1453 Helping Hand
タグ : / 解いたユーザー数 228
作問者 :
shiomusubi496
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.
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もしくは右上の雲マークをクリックしてアカウントを作成してください。