#B4080. Counting Contests in Pig Calendar Year
Counting Contests in Pig Calendar Year
Counting Contests in Pig Calendar Year
ICPC (Interactive Clever Pig Contest) and CCPC (Classic Clever Pig Contest) are two internationally renowned pig contests. ICPC has been held annually starting from pig year \(a\) (including year \(a\)), with \(b\) contests every year. Similarly, CCPC began in pig year \(c\) (including year \(c\)), with \(d\) contests each year.
Given a pig year \(x\), determine the total number of contests held in that year. The formula is given by:
\[ \text{Total Contests} = \begin{cases} b, & \text{if } x \geq a \\ 0, & \text{otherwise} \end{cases} + \begin{cases} d, & \text{if } x \geq c \\ 0, & \text{otherwise} \end{cases} \]
inputFormat
The input consists of five integers \(a\), \(b\), \(c\), \(d\), and \(x\) in one line, separated by spaces.
\(a\): the starting pig year for ICPC, \(b\): number of contests for ICPC per year, \(c\): the starting pig year for CCPC, \(d\): number of contests for CCPC per year, and \(x\): the pig year to query.
outputFormat
Output the total number of contests held in pig year \(x\) as a single integer.
sample
2018 3 2020 2 2017
0