#95. 数组元素条件修改

    ID: 95 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-2gesp2模拟循环结构

数组元素条件修改

Array Modification

Background

Congcong is studying a special array transformation rule. He has an integer array and wants to perform a series of operations on it, updating certain elements based on specific conditions.

Problem Description

For each multiple of 1010 in the given array, change all the values following it to be that multiple of 1010, until encountering another multiple of 1010. So {2,10,3,4,20,5}\{2, 10, 3, 4, 20, 5\} yields {2,10,10,10,20,20}\{2, 10, 10, 10, 20, 20\}.

Input Format

Input is given from standard input in the following format.

a_1 a_2 ... a_n

Where aia_i are integer elements of the array, separated by spaces.

Output Format

Output is printed to standard output in the following format.

b_1, b_2, ..., b_n

Where bib_i are the elements of the modified array, separated by commas and spaces.

Sample

[2 10 3 4 20 5]
[2, 10, 10, 10, 20, 20]
[10 1 20 2]
[10, 10, 20, 20]
[10 1 9 20]
[10, 10, 10, 20]

Sample Explanation

For the first sample [2 10 3 4 20 5]:

  • Element 2 is not a multiple of 1010, it remains unchanged.
  • Element 10 is a multiple of 1010. The subsequent elements 3 and 4 are changed to 10.
  • Element 20 is a multiple of 1010. The subsequent element 5 is changed to 20. The final array becomes [2, 10, 10, 10, 20, 20].

Constraints

Time limit: 1s, Memory limit: 1024KiB for each test case.