You are provided an array A of size N 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 N denoting the size of array A
  • Second line: N space-separated integers.
Output format
If the number is divisible by 10, then print Yes. Otherwise, print No.
Constraints
1N1050A[i]105
SAMPLE INPUT
5
85 25 65 21 84
SAMPLE OUTPUT
No
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-


import java.util.*;
class nrml
{
    public static void main(String... args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s1 = "";
        int[] arr = new int[n];
        for(int i=0; i<n; i++)
            arr[i] = sc.nextInt();
        if(arr[n-1]%10 == 0)
        System.out.println("Yes");
        else
        System.out.println("No");
    }
}

Post a Comment

Previous Post Next Post