User's AC Ratio

96.8% (30/31)

Submission's AC Ratio

36.0% (36/100)

Description

Baluteshih is doing a fake uniformly accelerated motion on a number line.
He starts at $x_0$.
The initial velocity is $v_0$.
The acceleration is $a$.
And he do this motion last for $t$ seconds.

This motion is different from normal uniformly accelerated motion.
At every second, he move $v$ units.
And then his $v$ will increase $a$.

Calculate the final position after he finish this motion.

For example:
Baluteshih starts at $5$ (which is $x_0$).
And his initial velocity is $3$ (which is $v_0$).
The acceleration is $2$ (which is $a$).
And $t=4$.

At beginning, let $v=v_0=3$
After $1$ second, he will stand on $8$, then $v$ increases $2$.($v\Rightarrow5$)
After $2$ seconds, he will stand on $13$, $v$ increases $2$.($v\Rightarrow7$)
After $3$ seconds, he will stand on $20$, $v$ increases $2$.($v\Rightarrow9$)
After $4$ seconds, he will stand on $29$.

After he finished this motion, he stand on $29$, so the answer is $29$.

Input Format

One line contains four integers $x_0,v_0,a,t$.

  • $|x_0|\leq10^ 9$
  • $|v_0|, |a|\leq10^ 4$
  • $0\leq t\leq3\times10^ 6$

Output Format

One line contains an integer which represents the final position.

Sample Input 1

5 3 2 4

Sample Output 1

29

Hints

Problem Source

Subtasks

No. Testdata Range Constraints Score
1 0~8 $x_0=a=0,t\leq10^ 4$ 10
2 0~17 $a=0,t\leq10^ 4$ 6
3 0~26 $|a|\leq5, t\leq10^ 4$ 14
4 0~35 No specified restriction 5

Testdata and Limits

No. Time Limit (ms) Memory Limit (KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1 2 3 4
1 1000 65536 65536 1 2 3 4
2 1000 65536 65536 1 2 3 4
3 1000 65536 65536 1 2 3 4
4 1000 65536 65536 1 2 3 4
5 1000 65536 65536 1 2 3 4
6 1000 65536 65536 1 2 3 4
7 1000 65536 65536 1 2 3 4
8 1000 65536 65536 1 2 3 4
9 1000 65536 65536 2 3 4
10 1000 65536 65536 2 3 4
11 1000 65536 65536 2 3 4
12 1000 65536 65536 2 3 4
13 1000 65536 65536 2 3 4
14 1000 65536 65536 2 3 4
15 1000 65536 65536 2 3 4
16 1000 65536 65536 2 3 4
17 1000 65536 65536 2 3 4
18 1000 65536 65536 3 4
19 1000 65536 65536 3 4
20 1000 65536 65536 3 4
21 1000 65536 65536 3 4
22 1000 65536 65536 3 4
23 1000 65536 65536 3 4
24 1000 65536 65536 3 4
25 1000 65536 65536 3 4
26 1000 65536 65536 3 4
27 1000 65536 65536 4
28 1000 65536 65536 4
29 1000 65536 65536 4
30 1000 65536 65536 4
31 1000 65536 65536 4
32 1000 65536 65536 4
33 1000 65536 65536 4
34 1000 65536 65536 4
35 1000 65536 65536 4