CF1575G.GCD Festival

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Mr. Chanek has an array aa of nn integers. The prettiness value of aa is denoted as:

sum_i=1nsum_j=1ngcd(a_i,a_j)cdotgcd(i,j)\\sum\_{i=1}^{n} {\\sum\_{j=1}^{n} {\\gcd(a\_i, a\_j) \\cdot \\gcd(i, j)}}

where gcd⁡(x,y)\gcd(x, y) denotes the greatest common divisor (GCD) of integers xx and yy.

In other words, the prettiness value of an array aa is the total sum of gcd⁡(ai,aj)⋅gcd⁡(i,j)\gcd(a_i, a_j) \cdot \gcd(i, j) for all pairs (i,j)(i, j).

Help Mr. Chanek find the prettiness value of aa, and output the result modulo 109+710^9 + 7!

陈先生有一个包含 nn 个整数的数组 aa。数组 aa 的“美观值”定义为:

∑i=1n∑j=1ngcd⁡(ai,aj)⋅gcd⁡(i,j)\sum_{i=1}^{n} {\sum_{j=1}^{n} {\gcd(a_i, a_j) \cdot \gcd(i, j)}}

其中 gcd⁡(x,y)\gcd(x, y) 表示整数 xx 和 yy 的最大公约数(GCD)。

换言之,数组 aa 的美观值即对所有数对 (i,j)(i, j) 的 gcd⁡(ai,aj)⋅gcd⁡(i,j)\gcd(a_i, a_j) \cdot \gcd(i, j) 之和。

请帮助陈先生计算数组 aa 的美观值,并将结果对 109+710^9 + 7 取模后输出!

输入格式

The first line contains an integer nn (2≤n≤1052 \leq n \leq 10^5).

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1051 \leq a_i \leq 10^5).

第一行包含一个整数 nn(2≤n≤1052 \leq n \leq 10^5)。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1051 \leq a_i \leq 10^5)。

输出格式

Output an integer denoting the prettiness value of aa modulo 109+710^9 + 7.

输出一个整数,表示 aa 的“美观度”值对 109+710^9 + 7 取模的结果。

输入输出样例

  • 输入#1

    5
    3 6 2 1 4

    输出#1

    77

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

首页