#abc304f. F - Shift Table

F - Shift Table

Score : 525525 points

问题描述

Takahashi 和 Aoki 将在接下来的 NN 天内兼职工作。
Takahashi 的轮班计划由字符串 SS 给出,其中 SS 的第 ii 个字符是 # 表示他在第 ii 天上班,. 表示他在第 ii 天缺席。
基于此,Aoki 按照以下方式创建了他的轮班计划:

  • 首先,取一个不等于 NN 的正整数 MM,要求它是 NN 的因子。
  • 其次,决定前 MM 天的出勤情况。
  • 最后,按照顺序对 i=1,2,,NMi = 1, 2, \ldots, N - M,决定第 (M+i)(M + i) 天的出勤情况,使其与第 ii 天的出勤情况相同。

请注意,不同的 MM 值可能会导致相同的最终轮班计划。

找出满足条件的不同 Aoki 轮班计划的数量:在 NN 天中,Takahashi 和 Aoki 至少有一个每天都在工作,并将结果对 998244353998244353 取模。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Takahashi and Aoki will work part-time for the next NN days.
Takahashi's shift schedule is given by the string SS, where the ii-th character of SS is # if he works on the ii-th day, and . if he is absent on the ii-th day.
Based on this, Aoki created his shift schedule as follows.

  • First, take a positive divisor MM of NN that is not equal to NN.
  • Next, decide the attendance for the first MM days.
  • Finally, for i=1,2,,NMi = 1, 2, \ldots, N - M in this order, decide the attendance for the (M+i)(M + i)-th day so that it matches the attendance for the ii-th day.

Note that different values of MM 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 NN days, modulo 998244353998244353.

Constraints

  • NN is an integer between 22 and 10510^5, inclusive.
  • SS is a string of length NN consisting of # and ..

Input

The input is given from Standard Input in the following format:

NN

SS

Output

Print the answer.

Sample Input 1

6
##.#.#

Sample Output 1

3

Takahashi works on days 11, 22, 44, and 66.
Let TT be the string representing Aoki's shift schedule, where the ii-th character of TT is # if he works on the ii-th day, and . if he is absent on the ii-th day.
There are three possible strings for TT: ######, #.#.#., and .##.##.

The first shift schedule can be realized by choosing M=1M = 1 or 22 or 33, the second by choosing M=2M = 2, and the third by choosing M=3M = 3.

Sample Input 2

7
...####

Sample Output 2

1

Sample Input 3

12
####.####.##

Sample Output 3

19

update @ 2024/3/10 08:34:40