CBOJ Fall Contest Problem 1 - Rule of Four
Bob has been given a large number!
As a big fan of the number \(4\), Bob wants his large number to be divisible by \(4\). Is it possible for Bob to reorder the digits to find a number that is divisible by \(4\)? Output YES
if there is a valid number and NO
otherwise.
Note that a number is invalid if it has leading 0s.
Input Specification
The first and only line of the input will contain a positive integer \(N\) \((0 \lt N \le 10^9)\). \(N\) will not have leading 0s.
Output Specification
On a single line output YES
if there is a valid number and NO
otherwise.
Scoring
Your code will be graded against all \(16\) testcases. Your in-contest score will be equal to \(100 \cdot \frac{x}{16}\), where \(x\) is the number of cases that match the expected output.
Sample Input 1
601
Sample Output 1
YES
Sample Explanation 1
Bob can reorder \(N\) into 160
, which is a multiple of \(4\). Note that the ordering 016
is invalid, making 160
the only valid ordering.
Sample Input 2
41
Sample Output 2
NO
Sample Explanation 2
The only two possible orderings are 41
and 14
, neither of which are divisible by \(4\).
Comments