#P3926. SAC E#1 - 一道不可做题 Jelly

SAC E#1 - 一道不可做题 Jelly

Description

SOL 君 likes eating konjac jelly, and SOL 菌 also likes konjac jelly.

One day, they were playing Hearthstone together, and SOL 菌 was going to serve konjac jelly to his guest.

Konjac jelly is usually stored in a refrigerator at aa degrees. However, it is too cold right after being taken out and needs to be heated. SOL 菌 plans to heat the konjac jelly with a magical electric stove. According to observation, it has the following behavior:

  1. When the jelly is below cc degrees, it heats by 11 degree every pp units of time.
  2. When the jelly is exactly cc degrees, it needs qq units of time to thaw (everyone knows that during a phase change the temperature does not change... SOL 菌 believes jelly is crystalline).
  3. After thawing is complete, it heats by 11 degree every rr units of time.

SOL wants to know the temperature of the jelly after heating for xx units of time.

The temperature is floored. That is, if the heating ends with less than pp (or qq) units of time, then during this final short period the temperature does not change at all.

Input Format

The input contains a single line with 66 integers: a,c,p,q,r,xa, c, p, q, r, x.

Output Format

Output a single integer: the required temperature.

-10 0 2 1 3 26

1
-10 0 2 1 3 27
2

Hint

For 30%30\% of the testdata, a,c200|a|, |c| \leq 200, x100x \leq 100.

For 60%60\% of the testdata, a,c2×109|a|, |c| \leq 2 \times 10^9, x100x \leq 100.

For 100%100\% of the testdata, a,c2×109|a|, |c| \leq 2 \times 10^9, 1x,p,q,r1091 \leq x, p, q, r \leq 10^9.

The testdata may have a=ca = c, which should be considered as the not-yet-thawed state.

Hint: Please use the long long data type.

Translated by ChatGPT 5