atcoder#ABC304F. [ABC304F] Shift Table
[ABC304F] Shift Table
Score : points
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.
6
##.#.#
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 .
7
...####
1
12
####.####.##
19