Editorial for GlobeX Cup '18 J3 - Good Numbers
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For each integer, , we can loop from
to
, and check if
is divisible by any
. If it is divisible, then
is not a prime. Otherwise, it is.
We can then sum up the digits, and perform the same prime checking.
If both checks are satisfied, then is a good number.
Be wary of , as
is not a prime.
Time Complexity:
Comments