PROBLEM LINK: Div-3 Contest
Author: Bhagya , Rishika
Tester: Rishika
Editorialist: Bhagya
DIFFICULTY:
EASY
PREREQUISITES:
PROBLEM:
if the sum of digits which are even is divisible by 4 or if number of sum of digits which are odd is divisible by 3.
QUICK EXPLANATION:
A car having a particular number will be allowed to run on Sunday i.e. if the sum of digits which are even is divisible by 4 or if number of sum of digits which are odd is divisible by 3. find out which car numbered N will be allowed to run on Sunday?
EXPLANATION:
Due to an immense rise in Pollution, Gujarat’s Chief Minister has decided to follow the Odd and Even Rule Ahmedabad like Delhi. The scheme is as follows, each car will be allowed to run on Sunday if the sum of digits which are even is divisible by 4 or sum of digits which are odd in that number is divisible by 3. However to check every car for the above criteria can’t be done by the Ahmedabad Police. You need to help Ahmedabad Police by finding out if a car numbered N will be allowed to run on Sunday?
Constraints
N<=1000 Car No >=0 && Car No <=1000000000
SOLUTIONS:
import java.util.*;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0)
{
int n = sc.nextInt();
int evenSum = 0;
int oddSum = 0;
while(n > 0)
{
int rem = n % 10;
if(rem % 2 == 0)
evenSum += rem;
else
oddSum += rem;
n = n/ 10;
}
if(evenSum % 4 == 0 || oddSum % 3 == 0)
System.out.println("Yes");
else
System.out.println("No");
}
}
}