## Back To School '18: The Golden Porcupine

View as PDF

Points: 15 (partial)
Time limit: 0.6s
Java 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Ohani was tired of sitting in a mall, watching people hold hands. He hates public displays of affection (PDA). So, he decided to take a walk. He was walking through a magical forest when he came across a porcupine. He noticed that the porcupine's body was completely made of gold. The porcupine said:

Over a period of seconds, I will shoot quills out in total. The quill exists only between the and seconds (inclusive).

The height of the can be expressed as , where , , and are constants for the quill and is the number of seconds the quill has been in the air. For the quill, at time , .

These quills have magical gravity and pass through anything, so it's perfectly fine for to be more than or the height of a quill to be less than at any point in time.

Can you tell me the sum of the heights of all the quills at each second in time between and inclusive?

Ohani was able to solve the problem and get home just in time to play with legos with his brother. Ohani loves legos, and his brother is a lego lover too.

#### Input Specification

The first line will contain two integers, .

The next lines will each contain five integers, .

#### Output Specification

Print integers on one line, the integer representing the sum of heights of quills at the second in time.

No further constraints.

#### Sample Input

2 6
1 6 1 3 2
3 4 2 2 -200

#### Sample Output

2 6 -188 -176 30 42

#### Explanation of Sample Input

The first quill's trajectory is shown as follows:

The second quill's trajectory is shown as follows:

At the second, the sum of the heights is only quill at as quill does not exist yet .

At the second, the sum of the heights is only quill at as quill does not exist yet .

At the second, the sum of the heights is quill at and quill at .

At the second, the sum of the heights is quill at and quill at .

At the second, the sum of the heights is only quill at as quill no longer exists .

At the second, the sum of the heights is only quill at as quill no longer exists .

• commented on July 15, 2020, 4:39 p.m.

The height of the quill can be expressed as .

I assume the is supposed to be .

• commented on July 16, 2020, 10:14 p.m.

Fixed! Thanks for pointing it out :)

• commented on Oct. 10, 2018, 1:56 a.m.

nice problem