A824.Phone Numbers--Platinum
NOI/NOI+/CTSC
通过率:0%
时间限制:4.00s
内存限制:128MB
题目描述
Bessie has a new cell phone with nine buttons, laid out as follows:
123
456
789
Bessie is trying to type out a given phone number in a hurry, so she decides
to save time by pressing multiple buttons at the same time with one of her
hooves. Specifically, Bessie's hoof might press a single digit, two digits
that share a side (for twelve possible pairs in total), or four digits that
form a square (1245, 2356, 4578, or 5689).
For example, if the phone number Bessie is trying to type is 123659874, she
might attempt to save time by
- Pressing 1 and 2 at the same time.
- Pressing 3.
- Pressing 6, 5, 9, and 8 at the same time.
- Pressing 7 and 4 at the same time.
Unfortunately, Bessie drastically overestimated her skill at performing this
task - if Bessie's hoof presses multiple buttons at the same time, then all
of the digits will be typed in arbitrary order. So if Bessie attempts the
above sequence of presses, she may end up typing 123596847 or 213659874
instead (or one of many other possibilities).
Given a sequence of digits that Bessie has typed, count the number of phone
numbers that she could have been trying to type modulo 109+7.
Note: The time limit for this problem is 4 seconds (twice the default).
输入格式
The first line contains T, the number of independent test cases. Each of the next T lines contains a nonempty string of digits, representing the sequence Bessie typed.
输出格式
For each test case, the number of phone numbers Bessie might have been trying
to type modulo 109+7.
输入输出样例
输入#1
5 1478 4455 5968 31313211 123659874
输出#1
5 2 24 3 255
说明/提示
For the first test case, Bessie might have been trying to type any of the following five phone numbers:
1478
1487
4178
4187
1748
For example, if Bessie was trying to type 4187, she might have pressed 1 and 4 at the same time, then pressed 7 and 8 at the same time. For the third test case, the digits form a square, so Bessie might have been trying to type any permutation of the input sequence.
数据范围
所有数据满足 1≤T≤10;每个字符串非空,且只包含数字 1 至 9;所有字符串总长度不超过 105。此外:
| 输入文件 | 数据范围 |
|---|---|
| 02.in–03.in | 每个字符串长度不超过 8 |
| 04.in–05.in | 字符串只包含数字 1,2,3 |
| 06.in–07.in | 字符串不包含数字 5 |
| 08.in–09.in | 字符串只包含数字 5,6,8,9 |
| 10.in–12.in | 所有字符串总长度不超过 102 |
| 13.in–15.in | 所有字符串总长度不超过 103 |
| 16.in–18.in | 所有字符串总长度不超过 104 |
| 19.in–21.in | 无其他范围限制 |
输入解题思路,AI测评打分。不知道怎么写?