#C8568. Valid Kingdom Sequence
Valid Kingdom Sequence
Valid Kingdom Sequence
You are given a sequence of digits. You need to determine whether this sequence is valid based on the following kingdom rules:
- The sequence must not start with a '0'.
- The length of the sequence must be a prime number. In mathematical terms, if we denote the length by \(L\), then \(L\) must be a prime number.
- The sequence must not be a palindrome, i.e. it should not read the same forwards and backwards.
If all these conditions are satisfied, output VALID
; otherwise, output INVALID
.
Example:
Input: 239 Output: VALID</p>Input: 12321 Output: INVALID
inputFormat
The input consists of a single line containing the sequence of digits. The sequence is provided via standard input.
Constraints: The sequence is non-empty and consists only of digit characters.
outputFormat
Output a single line to standard output with the word VALID
if the sequence meets all the specified rules, or INVALID
otherwise.
239
VALID