Input Format:
The first line of the input contains a number N representing the number of elements in array A.
The second line of the input contains N numbers separated by a space. (after the last elements, there is no space)
Output Format:
Print the resultant array elements separated by a space. (no space after the last element)
Example:
Input:
4
2 5 3 1
Output:
3883
Explanation:
Here array A is [1,2,3,4] and reverse of this array is [4,3,2,1] and hence the resultant array is [5,5,5,5]
SOURCE CODE:
import math
size=int(input())
list1=[]
for x in input().split():
num=int(x)
list1=list1+[num]
for i in range(math.ceil(size/2)):
list1[i]=list1[size-1-i]=list1[i]+list1[size-1-i]
for i in range(size-1):
print(list1[i],end=" ")
print(list1[size-1],end="")
Comments
Post a Comment
If you have any doubts? Please let me know.