#K81177. Deterministic Password Generator
Deterministic Password Generator
Deterministic Password Generator
You are given an integer \(N\). Your task is to generate a password of exactly \(N\) characters that meets the following criteria:
- The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character from the set
!@#$%^&*()-+
. - The first four characters of the password are fixed as
A
(uppercase),a
(lowercase),0
(digit), and!
(special character). This ensures the complexity criteria. - For \(N \ge 4\), the remaining characters are generated deterministically using the cyclic base string "Aa0!". When adding a new character, if it is identical to the last character in the current password, the next character in the cycle is chosen instead. This guarantees that no two adjacent characters are the same.
- If \(N < 4\) it is impossible to form a password meeting all the criteria. In that case, output "IMPOSSIBLE".
For example:
- For \(N = 3\), output:
IMPOSSIBLE
. - For \(N = 4\), output:
Aa0!
. - For \(N = 8\), output:
Aa0!Aa0!
.
inputFormat
The input consists of a single integer \(N\) provided via standard input.
Input Format:
N
outputFormat
Output a single string to standard output:
- If \(N \ge 4\), output a password satisfying all the constraints.
- If \(N < 4\), output
IMPOSSIBLE
.
3
IMPOSSIBLE