Thursday, 23 November 2023

PROGRAM(PYTHON) :-TO CHECK WEATHER THE NUMBER FORMES BY LAST DIGIT OF AN ARRAY IS DIVISIBLE BY 10 OR NOT??

HAY THANK FOR VISIT
Problem

You are provided an array  of size  that contains non-negative integers. Your task is to determine whether the number that is formed by selecting the last digit of all the N numbers is divisible by 10.

Note: View the sample explanation section for more clarification.

Input format

  • First line: A single integer  denoting the size of array 
  • Second line:  space-separated integers.

Output format

If the number is divisible by 10, then print . Otherwise, print .

Constraints
11050[]105

Sample Input
5
85 25 65 21 84
Sample Output
No
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Last digit of 85 is 5.
Last digit of 25 is 5.
Last digit of 65 is 5.
Last digit of 21 is 1.
Last digit of 84 is 4.
Therefore the number formed is 55514 which is not divisible by 10.


SOLUTION:-


num=0;
d=0;
N = int(input())
data = [int(x) for x in input().split()]
for i in range(N):
    d=data[i]
    num=num*10+d
if num%10==0:
    ans="Yes"
else:
    ans="No"

# Write your code here
# ans =

print(ans)

No comments:

Post a Comment

HAY THAKYOU FOE VISIT

Program(python):-Find duplicates in an array (Geeks for geek problem)

QUESTION:- Given an array  a  of size  N  which contains elements from  0  to  N-1 , you need to find all the elements occurring more than o...