DIGARR Editorial

PROBLEM LINK:

Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4

Setter: Srikkanth R
Tester: Harris Leung
Editorialist: Jakub Safin, Pratiyush Mishra

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

Given a positive integer N, determine if it is possible to rearrange the digits of N (in decimal representation) and obtain a multiple of 5.

For example, when N=108, we can re-arrange it’s digits to construct 180=36⋅5 which is a multiple of 5.

EXPLANATION:

For each test case, we have to check if rearrangement of digits can produce a multiple of 5. An integer is multiple of 5 if the last digit is either 5 or 0.

Since the inputs are free from leading zeroes so we just need to check if any digit in N is 5 or 0. We have to print Yes if 5 or 0 are contained in N then, otherwise No.

TIME COMPLEXITY:

O(D) for each test case, where D is the number of digits of input N.

SOLUTION:

Editorialist’s Solution
Setter’s Solution
Tester’s Solution