CF594D.REQ

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Today on a math lesson the teacher told Vovochka that the Euler function of a positive integer φ(n) is an arithmetic function that counts the positive integers less than or equal to n that are relatively prime to n. The number 1 is coprime to all the positive integers and φ(1) = 1.

Now the teacher gave Vovochka an array of n positive integers _a_1, _a_2, ..., a__n and a task to process q queries l__i r__i — to calculate and print modulo 109 + 7. As it is too hard for a second grade school student, you've decided to help Vovochka.

今天数学课上,老师告诉沃沃奇卡:正整数 $ n $ 的欧拉函数 $ \varphi(n) $ 是一个算术函数,用于计算所有小于等于 $ n $ 且与 $ n $ 互质的正整数的个数。数字 $ 1 $ 与所有正整数互质,且 $ \varphi(1) = 1 $。

现在老师给了沃沃奇卡一个包含 $ n $ 个正整数 $ a_1,,a_2,,\dots,,a_n $ 的数组,以及 $ q $ 个查询 $ l_i;r_i $,要求计算并输出

对 $ 10^9 + 7 $ 取模的结果。由于这对一名二年级学生来说过于困难,你决定帮助沃沃奇卡。

输入格式

The first line of the input contains number n (1 ≤ n ≤ 200 000) — the length of the array given to Vovochka. The second line contains n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 106).

The third line contains integer q (1 ≤ q ≤ 200 000) — the number of queries. Next q lines contain the queries, one per line. Each query is defined by the boundaries of the segment l__i and r__i (1 ≤ l__i ≤ r__i ≤ n).

输入的第一行包含一个整数 nn(1≤n≤200 0001 \leq n \leq 200\,000)—— 表示给 Vovochka 的数组长度。
第二行包含 nn 个整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n(1≤ai≤1061 \leq a_i \leq 10^6)。

第三行包含一个整数 qq(1≤q≤200 0001 \leq q \leq 200\,000)—— 表示查询的数目。
接下来的 qq 行每行包含一个查询,每个查询由区间边界 lil_i 和 rir_i 定义(1≤li≤ri≤n1 \leq l_i \leq r_i \leq n)。

输出格式

Print q numbers — the value of the Euler function for each query, calculated modulo 109 + 7.

输出 q 个数——每个查询对应的欧拉函数值,对 109+710^9 + 7 取模。

输入输出样例

  • 输入#1

    10
    1 2 3 4 5 6 7 8 9 10
    7
    1 1
    3 8
    5 6
    4 8
    8 10
    7 9
    7 10

    输出#1

    1
    4608
    8
    1536
    192
    144
    1152
  • 输入#2

    7
    24 63 13 52 6 10 1
    6
    3 5
    4 7
    1 7
    2 4
    3 6
    2 6

    输出#2

    1248
    768
    12939264
    11232
    9984
    539136

说明/提示

In the second sample the values are calculated like that:

  • φ(13·52·6) = φ(4056) = 1248
  • φ(52·6·10·1) = φ(3120) = 768
  • φ(24·63·13·52·6·10·1) = φ(61326720) = 12939264
  • φ(63·13·52) = φ(42588) = 11232
  • φ(13·52·6·10) = φ(40560) = 9984
  • φ(63·13·52·6·10) = φ(2555280) = 539136

在第二个样例中,各值的计算方式如下:

  • φ(13·52·6) = φ(4056) = 1248
  • φ(52·6·10·1) = φ(3120) = 768
  • φ(24·63·13·52·6·10·1) = φ(61326720) = 12939264
  • φ(63·13·52) = φ(42588) = 11232
  • φ(13·52·6·10) = φ(40560) = 9984
  • φ(63·13·52·6·10) = φ(2555280) = 539136

输入解题思路,AI测评打分。不知道怎么写?

首页