C. LCM Query

Codeforces
IDCF10057C
Time4000ms
Memory256MB
Difficulty
English · Original
Formal · Original
De Prezer loves lcm (Least Common Multiple).Ha has got a sequence a1, a2, ..., an but doesn't know how to calculate lcm of two numbers. De Prezer also loves query.So he asks you to answer to m queries on this sequence. In each query, he gives you number x and you should print the following number : lcm(ai, ai + 1, ..., ai + x - 1) Answer can be very large, so print it modulo 109 + 7 . The first line of input consists of 2 integers n and m. The second line of input contains n space separated integers a1, a2, ..., an. The next m lines, each line contains an integer x. 1 ≤ n ≤ 2 * 104 1 ≤ m ≤ 106 1 ≤ ai ≤ 60 (For each 1 ≤ i ≤ n) 1 ≤ x ≤ n Print m lines, each answer to one query. ## Input The first line of input consists of 2 integers n and m.The second line of input contains n space separated integers a1, a2, ..., an.The next m lines, each line contains an integer x.1 ≤ n ≤ 2 * 1041 ≤ m ≤ 1061 ≤ ai ≤ 60 (For each 1 ≤ i ≤ n)1 ≤ x ≤ n ## Output Print m lines, each answer to one query. [samples]
**Definitions** Let $ a, b \in \mathbb{Z} $ be two positive integers represented as decimal strings, with $ 1 \leq a, b \leq 10^{1000} $. **Constraints** - $ a $ and $ b $ are given as decimal strings (possibly with leading zeros in input, but represent positive integers). - The number of digits in $ a $ and $ b $ is at most $ 1000 $. **Objective** Compute $ c = a + b $, and output $ c $ as a decimal integer (without leading zeros).
API Response (JSON)
{
  "problem": {
    "name": "C. LCM Query",
    "description": {
      "content": "De Prezer loves lcm (Least Common Multiple).Ha has got a sequence a1, a2, ..., an but doesn't know how to calculate lcm of two numbers. De Prezer also loves query.So he asks you to answer to m querie",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 4000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10057C"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "De Prezer loves lcm (Least Common Multiple).Ha has got a sequence a1, a2, ..., an but doesn't know how to calculate lcm of two numbers.\n\nDe Prezer also loves query.So he asks you to answer to m querie...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ a, b \\in \\mathbb{Z} $ be two positive integers represented as decimal strings, with $ 1 \\leq a, b \\leq 10^{1000} $.\n\n**Constraints**  \n- $ a $ and $ b $ are given as decimal st...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments