#P5440. 【XR-2】奇迹
【XR-2】奇迹
Description
We define a date as an 8-digit number. Digits form the year, digits form the month, and digits form the day. If a part has fewer digits, it is padded with . Also, the day represented by the date must really exist, and the year ranges from .
All miracle dates share the same property: the 2-digit number formed by the “day”, the 4-digit number formed by “month + day”, and the 8-digit number formed by “year + month + day” are all prime numbers. However, not every date with this property will necessarily have a miracle.
Now you are given a date that may have a miracle, but unfortunately this date is incomplete: among the 8 digits, some digits may be unknown. You need to determine how many possible dates it could be, so that you can be fully prepared to welcome the miracle.
Input Format
This problem has multiple test cases.
The first line contains a positive integer , the number of test cases.
The next lines each contain an 8-character string. If the -th character is -, it means the -th digit of the date is unknown; otherwise, it means the -th digit of the date is the digit at position in the string.
Output Format
For each test case, output one integer per line, representing the answer.
2
53-7-3-7
20190629
6
0
Hint
[Sample Explanation]
The 6 possible dates for 53-7-3-7 are:
53070307
53070317
53170307
53370307
53570317
53770307
[Constraints]
There are test points in total. Let be the number of - characters in the 8-character string.
For the first test points, in the -th test point it is guaranteed that .
For of the testdata, it is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号