CF1575G.GCD Festival
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mr. Chanek has an array a of n integers. The prettiness value of a is denoted as:
sum_i=1nsum_j=1ngcd(a_i,a_j)cdotgcd(i,j)
where gcd(x,y) denotes the greatest common divisor (GCD) of integers x and y.
In other words, the prettiness value of an array a is the total sum of gcd(ai,aj)⋅gcd(i,j) for all pairs (i,j).
Help Mr. Chanek find the prettiness value of a, and output the result modulo 109+7!
陈先生有一个包含 n 个整数的数组 a。数组 a 的“美观值”定义为:
i=1∑nj=1∑ngcd(ai,aj)⋅gcd(i,j)
其中 gcd(x,y) 表示整数 x 和 y 的最大公约数(GCD)。
换言之,数组 a 的美观值即对所有数对 (i,j) 的 gcd(ai,aj)⋅gcd(i,j) 之和。
请帮助陈先生计算数组 a 的美观值,并将结果对 109+7 取模后输出!
输入格式
The first line contains an integer n (2≤n≤105).
The second line contains n integers a1,a2,…,an (1≤ai≤105).
第一行包含一个整数 n(2≤n≤105)。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤105)。
输出格式
Output an integer denoting the prettiness value of a modulo 109+7.
输出一个整数,表示 a 的“美观度”值对 109+7 取模的结果。
输入输出样例
输入#1
5 3 6 2 1 4
输出#1
77
输入解题思路,AI测评打分。不知道怎么写?