#abc304f. F - Shift Table
F - Shift Table
Score : points
问题描述
Takahashi 和 Aoki 将在接下来的 天内兼职工作。
Takahashi 的轮班计划由字符串 给出,其中 的第 个字符是 #
表示他在第 天上班,.
表示他在第 天缺席。
基于此,Aoki 按照以下方式创建了他的轮班计划:
- 首先,取一个不等于 的正整数 ,要求它是 的因子。
- 其次,决定前 天的出勤情况。
- 最后,按照顺序对 ,决定第 天的出勤情况,使其与第 天的出勤情况相同。
请注意,不同的 值可能会导致相同的最终轮班计划。
找出满足条件的不同 Aoki 轮班计划的数量:在 天中,Takahashi 和 Aoki 至少有一个每天都在工作,并将结果对 取模。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi and Aoki will work part-time for the next days.
Takahashi's shift schedule is given by the string , where the -th character of is #
if he works on the -th day, and .
if he is absent on the -th day.
Based on this, Aoki created his shift schedule as follows.
- First, take a positive divisor of that is not equal to .
- Next, decide the attendance for the first days.
- Finally, for in this order, decide the attendance for the -th day so that it matches the attendance for the -th day.
Note that different values of may lead to the same final shift schedule.
Find the number of possible shift schedules for Aoki such that at least one of Takahashi and Aoki works on each of the days, modulo .
Constraints
- is an integer between and , inclusive.
- is a string of length consisting of
#
and.
.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
6
##.#.#
Sample Output 1
3
Takahashi works on days , , , and .
Let be the string representing Aoki's shift schedule, where the -th character of is #
if he works on the -th day, and .
if he is absent on the -th day.
There are three possible strings for : ######
, #.#.#.
, and .##.##
.
The first shift schedule can be realized by choosing or or , the second by choosing , and the third by choosing .
Sample Input 2
7
...####
Sample Output 2
1
Sample Input 3
12
####.####.##
Sample Output 3
19
update @ 2024/3/10 08:34:40