Mult!
InterviewTime limit1sMemory limit1024 MB
Scan a sequence of numbers and print each number that is a multiple of the first number of its current round, which then restarts the round.
- Level
Easy3 of 10
- Topics
- Implementation, Simulation, Math, Array
- Solved
- No attempts yet
Problem
Nora Mainder plays a game with her students to help them learn multiplication. She calls out a sequence of numbers, and the students must determine when she names a whole number multiple of the first number. When a student recognizes such a multiple, they must call out "Mult!", which ends the round. A new round then begins with a new initial number. Her students are very bright and never fail to spot a multiple, so they all shout at once: a "multitude" of shouts.
For example, if she calls out ", , , , ," the students all yell "Mult!" when she reaches , because it is a multiple of the first number, . If she begins a second round with the sequence ", , , ," the class calls out "Mult!" when she reaches , a multiple of the first number, .
Given a sequence of numbers called out by Nora over several rounds of the game, identify every number that should produce a shout of "Mult!"
Input
The first line of input contains an integer , , the length of the number sequence. The following lines contain the sequence, one number per line. All numbers in the sequence are positive integers less than or equal to . The sequence contains at least one complete round of the game, but it may end with an incomplete round.
Output
Print every element of the sequence that causes the class to shout "Mult!". Print each value on its own line.