Problem I. Count
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 42 Accepted Submission(s): 16
Problem Description
Multiple query, for each n, you need to get n i-1 ∑ ∑ [gcd(i + j, i - j) = 1] i=1 j=1
Input
On the first line, there is a positive integer T, which describe the number of queries. Next there are T lines, each line give a positive integer n, as mentioned above. T<=1e5, n<=2e7
Output
Your output should include T lines, for each line, output the answer for the corre- sponding n.
Sample Input
4 978 438 233 666
Sample Output
194041 38951 11065 89963
Source
Recommend
chendu | We have carefully selected several similar problems for you:
题意:求下面这个式子的值
n i-1 ∑ ∑ [gcd(i + j, i - j) = 1] i=1 j=1
分析:按照上面那个式子直接暴力打表容易得到上面式子的含义是1-n以内偶数的欧拉函数值加上奇数的欧拉函数值除以2的和(注意要快速打表,运用素数快速打表)
AC代码:
#include