B3. Rasta-making

Codeforces
IDCF10070B3
Time15000ms
Memory1024MB
Difficulty
English · Original
Formal · Original
Sequence of positive integers is given to you. A sequence of positive integers is called Rasta - made if and only if every two consecutive elements from this sequence are coprimes to each other. A Rasta - making operation on a sequence consists of choosing two non-coprime consecutive elements from it and divide them both by one of their common prime factors. For example, we can turn the seqeunce to with performing one operation. Phoulady number of a sequence is the minimum number of Rasta - making operations needed for turning it into a Rasta - made sequence. Construction number of a a sequence is the number of different sequences we can get by performing 0 or more Rasta - making operations. We show Phoulady number by F and Construction number by S. In all subtasks: Subtasks: Each subtask consists of one testcase. Input consists of two integers, n and M. Print the answer modulo 109 + 7 in a single line. ## Input Each subtask consists of one testcase.Input consists of two integers, n and M. ## Output Print the answer modulo 109 + 7 in a single line. [samples]
**Definitions** Let $ n, M \in \mathbb{Z}^+ $. Let $ \mathcal{S} $ be the set of all sequences $ A = (a_1, a_2, \dots, a_n) $ such that $ a_i \in \{1, 2, \dots, M\} $ for all $ i $. A sequence $ A $ is **#cf_span[Rasta-made]** if $ \gcd(a_i, a_{i+1}) = 1 $ for all $ i \in \{1, \dots, n-1\} $. A **#cf_span[Rasta-making] operation** on $ A $ selects an index $ i \in \{1, \dots, n-1\} $ such that $ \gcd(a_i, a_{i+1}) > 1 $, chooses a prime $ p \mid \gcd(a_i, a_{i+1}) $, and replaces $ a_i \leftarrow a_i/p $, $ a_{i+1} \leftarrow a_{i+1}/p $. Let $ F(A) $ be the minimum number of #cf_span[Rasta-making] operations to make $ A $ #cf_span[Rasta-made]. Let $ S(A) $ be the number of distinct sequences obtainable from $ A $ via any number of #cf_span[Rasta-making] operations. **Objective** Compute: $$ \sum_{A \in \mathcal{S}} F(A) \quad \text{and} \quad \sum_{A \in \mathcal{S}} S(A) $$ modulo $ 10^9 + 7 $. **Constraints** $ 1 \leq n \leq 50 $, $ 1 \leq M \leq 50 $.
API Response (JSON)
{
  "problem": {
    "name": "B3. Rasta-making",
    "description": {
      "content": "Sequence  of positive integers is given to you. A sequence of positive integers is called Rasta - made if and only if every two consecutive elements from this sequence are coprimes to each other.  A ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 15000,
      "memory_limit": 1048576
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10070B3"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Sequence  of positive integers is given to you. A sequence of positive integers is called Rasta - made if and only if every two consecutive elements from this sequence are coprimes to each other. \n\nA ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, M \\in \\mathbb{Z}^+ $.  \nLet $ \\mathcal{S} $ be the set of all sequences $ A = (a_1, a_2, \\dots, a_n) $ such that $ a_i \\in \\{1, 2, \\dots, M\\} $ for all $ i $.  \n\nA sequence ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments