Working with elements (insert, delete, shift)


Plus
Pin


Problem description Progress
ID 10385. Error
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Given an array of N elements.  Delete elements at the beginning and end until the sum of the array is a multiple of 5 (first the first, then the last, etc.).

The first line contains the number N (1<=N<=15)  - the number of elements of a one-dimensional array
The second line contains N integers (numbers are entered from the keyboard)

Sample input and output

Test number Input Output
1 4
2 6 4 5
6 4

ID 10384. Error
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Given an array of N elements.  Remove uneven symmetrical elements.

The first line contains the number N (1<=N<=15)  - the number of elements of a one-dimensional array
The second line contains N integers (numbers are entered from the keyboard)

Sample Input and Output

Test No. Input data Imprint
1
5
1 0 2 0 0
0 2 0
2
6
4 0 1 4 5 4 
4 4

ID 10383. Error
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Given an array of N elements.  Remove those elements, all elements less than the previous one

The first line contains the number N (1<=N<=15)  - the number of elements of a one-dimensional array
The second line contains N integers (numbers are entered from the keyboard)

Sample Input and Output

Test No. Input data Imprint
1
5
1 0 2 0 0
1  2
2
6
4 0 1 4 5 4 
4 4 5

ID 10382. Error
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Given an array of N elements.  Remove the longest sequence of zeros
(there are no sequences of the same length).

The first line contains the number N (1<=N<=20)  - the number of elements of a one-dimensional array
The second line contains N integers (numbers are entered from the keyboard)

Sample Input and Output

Test No. Input data Imprint
1
5
1 0 2 0 0
1 0 2
2
6
4 0 0 0 3 0 
4 3 0

ID 1875. Error
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Given an array of N elements (2<=N<=15). Remove from it all elements ending in 0

Input format:
At the input are given in the first line N - the number of elements of the array
The second line contains N numbers - the values ​​of the array elements

Output data format: Output the resulting array to a string

Example:
Input
5
43  -50  76  -84 100 

Conclusion
43  76 -84

ID 1878. Error
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Given an array of N positive elements greater than 1 (2<=N<=100). Insert the value of a before the first maximum element, the value of b after the first maximum element. 

Input format:
At the input are given in the first line N - the number of elements of the array
The second line contains number a and number b
The third line contains N numbers - the values ​​of the array elements

Output data format: Output the resulting array to a string

Example:
Input
5
100 200
43  50  76  84 100 

Conclusion
43 50 76 84 100 100 200

ID 1876. Error
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Given an array of N positive elements greater than 1 (2<=N<=100). After each element, insert its minimum divisor greater than 1.

Input format:
At the input are given in the first line N - the number of elements of the array
The second line contains N numbers - the values ​​of the array elements

Output data format: Output the resulting array to a string

Example:
Input
5
43  50  76  84 100 

Conclusion
43 43 50 2 76 2 84 2 100 2

ID 21991. Rotate Right
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Given an array of N elements (N<=100) 
Write a program that performs a right cyclic shift of even-numbered elements (element numbering starts from 0)

Input
On the first line, enter the value N. Next, on the second line, enter N numbers

Imprint
Output all elements of the converted array.

 

Examples
# Input Output
1
5
1 2 3 4 5
5 2 1 4 3

ID 1874. Inversion between two elements
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Given a one-dimensional array of dimension N (2 <= N <= 20). Invert elements that are between the maximum and minimum values ​​(the maximum and minimum values ​​should remain in their places).

Input
The first line contains the number N - the number of array elements. The second line contains the values ​​of the array elements.

Imprint
You need to display the resulting array.

 

Examples
# Input Output
1 4
1 2 3 4
1 3 2 4

ID 42273. Children in a circle
Темы: One-Dimensional Arrays    Working with elements (insert, delete, shift)   

Anna Nikolaevna plays a game with children in kindergarten. There are chairs in a circle. All chairs are numbered from 1 to N (1 <= N <= 100000). Children also have numbers from 1 to N. Initially, each child sits on a chair with the same number. That is, a child with number 1 sits on a stupa with number 1, a child with number 2 sits on a chair with number 2, and so on. Then Anna Nikolaevna claps her hands times  (|K| <= 100000) quietly or loudly. If Anna Nikolaevna claps her hands quietly, then all children should quickly transfer to K chairs to the right. If Anna Nikolaevna claps loudly, then all children should quickly transfer to K code> chairs to the left. 
To make it easier for Anna Nikolaevna to determine whether all the children moved correctly, write a program for her that would determine the position of each child after transplantation. 


You cannot use additional arrays (lists) in this task. Please note that you need to convert the existing array (list) and print it out as a whole, and not create a new one, even naming it with the same name (this is possible in Python).


Input

The first line is a natural number N, the second line N integers, and the last integer K . All numbers in the input do not exceed 109. If the number K > 0, this means that Anna Nikolaevna clapped her hands quietly. Number K < 0, which means Anna  Nikolaevna clapped her hands loudly.


Output

It is required to display the numbers of children who will occupy chairs from 1 to N after transplantation. 

 
Examples
# Input Output
1
5
5 3 7 4 6
3
7 4 6 5 3