#P8417. [THUPC 2022 决赛] 高性能计算导论集群登录密码复杂性策略
[THUPC 2022 决赛] 高性能计算导论集群登录密码复杂性策略
Background
Introduction to High-Performance Computing is a specialized elective course offered by the Department of Computer Science at T University. This course covers the basic concepts and principles of high-performance computing, common parallel programming models and basic ideas for writing parallel programs, basic methods for program performance analysis and optimization, and the relationship between computer architecture and program performance. To let students experience parallel programming, performance analysis, and optimization in practice, the course provides a cluster consisting of five servers. Each server is equipped with a socket core processor and GPU. Students enrolled in the course can do message-passing parallel programming, shared-memory parallel programming, and CUDA programming on the cluster. To prevent valuable computing resources from being abused (for example, secretly using the servers for crypto mining), the course has many rules for using the cluster, including requiring students to use strong cluster login passwords.
Problem Description
To ensure that students use sufficiently strong cluster login passwords, the course staff configured a password complexity policy on the cluster. At the beginning of the semester, every student receives a randomly generated initial password. After logging into the cluster with the initial password, the cluster requires the student to enter a new password. Only after changing the password can the student access the cluster normally. In this problem, we assume the password complexity policy is:
-
The password contains at least characters, and contains at least one digit and at least one letter.
-
The password must not contain consecutive identical characters. For example,
2333contains consecutive identical characters. -
The password must not contain an increasing sequence or decreasing sequence made of consecutive characters. Here, an increasing sequence is defined as a contiguous substring of one of the three strings
0123456789,ABCDEFGHIJKLMNOPQRSTUVWXYZ, andabcdefghijklmnopqrstuvwxyz. A decreasing sequence is the reverse of a contiguous substring of one of these three strings. For example:-
6789is an increasing sequence of length , andFEDis a decreasing sequence of length . -
90,AZ, andazare not increasing or decreasing sequences. -
GPUis not an increasing sequence because it is not contiguous. -
Defis not an increasing sequence because the letter cases are inconsistent (but it contains an increasing contiguous subsequenceefof length ). -
1112345678999is not an increasing sequence, but its subsequence123456789is increasing.
-
Assume the password consists only of digits and uppercase/lowercase letters. Among all passwords with length not exceeding , compute how many passwords satisfy the password complexity policy.
Input Format
The input contains one line with four positive integers , whose meanings are as described above.
Output Format
Output a non-negative integer, representing the number of passwords that satisfy the password complexity policy and have length not exceeding , modulo .
2 2 2 2
1040
12 24 3 4
718185656
100 10000000 6 6
146399052
Hint
[Sample 1 Explanation]
Because the password must contain at least one digit and at least one letter, there are valid passwords.
[Constraints]
It is guaranteed that , , .
[Hint]
If you do not want to remember a long and complex password, and do not want to type it manually every time you log in, you can also set up a public key for SSH login.
Translated by ChatGPT 5