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 .
Note: View the sample explanation section for more clarification.
Input format
If the number is divisible by , then print . Otherwise, print .
Constraints
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.
If the number is divisible by , then print . Otherwise, print .
Constraints
SAMPLE INPUT
5 85 25 65 21 84
SAMPLE OUTPUT
No
Explanation
Last digit of is .
Last digit of is .
Last digit of is .
Last digit of is .
Last digit of is .
Therefore the number formed is which is not divisible by .
Solution-
Last digit of is .
Last digit of is .
Last digit of is .
Last digit of is .
Therefore the number formed is which is not divisible by .
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