#AGC020E. [AGC020E] Encoding Subsets

[AGC020E] Encoding Subsets

Score : 14001400 points

Problem Statement

Consider the following set of rules for encoding strings consisting of 0 and 1:

  • Strings 0 and 1 can be encoded as 0 and 1, respectively.
  • If strings AA and BB can be encoded as PP and QQ, respectively, then string ABAB can be encoded as PQPQ.
  • If string AA can be encoded as PP and K2K \geq 2 is a positive integer, then string AA...AAA...A (AA repeated KK times) can be encoded as (PPxKK).

For example, string 001001001, among other possibilities, can be encoded as 001001001, 00(1(0x2)x2)1 and (001x3).

Let's call string AA a subset of string BB if:

  • AA and BB are equal in length and consist of 0 and 1;
  • for all indices ii such that AiA_i = 1, it's also true that BiB_i = 1.

You are given string SS consisting of 0 and 1. Find the total number of distinct encodings of all subsets of SS, modulo 998244353998244353.

Constraints

  • 1S1001 \leq |S| \leq 100
  • SS consists of 0 and 1.

Input

Input is given from Standard Input in the following format:

SS

Output

Print the total number of distinct encodings of all subsets of SS modulo 998244353998244353.

011
9

There are four subsets of SS:

  • 011 can be encoded as 011 and 0(1x2);
  • 010 can be encoded as 010;
  • 001 can be encoded as 001 and (0x2)1;
  • 000 can be encoded as 000, 0(0x2), (0x2)0 and (0x3).

Thus, the total number of encodings of all subsets of SS is 2+1+2+4=92 + 1 + 2 + 4 = 9.

0000
10

This time SS has only one subset, but it can be encoded in 1010 different ways.

101110
156
001110111010110001100000100111
363383189

Don't forget to take the result modulo 998244353998244353.