102590: [AtCoder]ABC259 A - Growth Record

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $100$ points

Problem Statement

Takahashi had his $N$-th birthday, when he was $T$ centimeters tall.
Additionally, we know the following facts:

  • In each year between Takahashi's birth ($0$-th birthday) and his $X$-th birthday, his height increased by $D$ centimeters. More formally, for each $i = 1, 2, \ldots, X$, his height increased by $D$ centimeters between his $(i-1)$-th birthday and his $i$-th birthday.
  • Between Takahashi's $X$-th birthday and his $N$-th birthday, his height did not change.

Find Takahashi's height on his $M$-th birthday, in centimeters.

Constraints

  • $0 \leq M \lt N \leq 100$
  • $1 \leq X \leq N$
  • $1 \leq T \leq 200$
  • $1 \leq D \leq 100$
  • Takahashi was at least $1$ centimeter tall at his birth.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $M$ $X$ $T$ $D$

Output

Print the answer as an integer.


Sample Input 1

38 20 17 168 3

Sample Output 1

168

In this sample, Takahashi was $168$ centimeters tall on his $38$-th birthday. Also, his height did not change between his $17$-th birthday and $38$-th birthday.
From these facts, we find that he was $168$ centimeters tall on his $20$-th birthday, so the answer is $168$.


Sample Input 2

1 0 1 3 2

Sample Output 2

1

In this sample, Takahashi was $1$ centimeter tall on his $0(=M)$-th birthday and $3(=T)$ centimeters tall on his $1(=N)$-st birthday.


Sample Input 3

100 10 100 180 1

Sample Output 3

90

Input

题意翻译

题意: 高桥君正在过他$N$岁的生日。此时他身高为$Tcm$. 高桥君从出生到$X$岁生日期间,每年长高$Dcm$.(严格来说是从$i-1$岁生日到$i$岁生日之间长高$Dcm$) 求高桥君$M$岁生日时的身高。 数据范围: + $0\le M<N \le 100$ + $1 \le X \le N$ + $1 \le T \le 200$ + $1\le D \le 100$

Output

分数:100分 部分 问题描述 高桥君在$N$岁生日时,身高为$T$厘米。 此外,我们还知道以下事实: - 在高桥君从出生(0岁生日)到他的第$X$个生日之间,他的身高每年增加$D$厘米。更正式地说,对于每个$i=1,2,\ldots,X$,他的身高在他第$(i-1)$个生日和第$i$个生日之间增加了$D$厘米。 - 在高桥君的第$X$个生日和第$N$个生日之间,他的身高没有变化。 找到高桥君在他第$M$个生日时的身高,以厘米为单位。 部分 约束条件 - $0\leq M

加入题单

上一题 下一题 算法标签: