Given the value of N, you will have to find the value of G. The definition of G is given below:
G=∑i=1i<N∑j=i+1j≤NGCD(i,j)G =\sum_{i=1}^{i<N}\sum_{j=i+1}^{j≤N}GCD(i, j)G=i=1∑i<N​j=i+1∑j≤N​GCD(i,j)
    Here GCD(i, j) means the greatest common divisor of integer i and integer j.
    For those who have trouble understanding summation notation, the meaning of G is given in the following code:

G=0;
for(i=1;i<N;i++)
for(j=i+1;j<=N;j++)
{G+=gcd(i,j);
}
/*Here gcd() is a function that finds
the greatest common divisor of the two
input numbers*/

Input
The input file contains at most 20000 lines of inputs. Each line contains an integer N (1 < N < 200001). The meaning of N is given in the problem statement. Input is terminated by a line containing a single zero.
Output
For each line of input produce one line of output. This line contains the value of G for the corresponding N. The value of G will fit in a 64-bit signed integer.
Sample Input
10
100
20000
0
Sample Output
67
13015
1153104356

问题链接:UVA11424 GCD - Extreme (I)
问题简述:(略)
问题分析:欧拉函数问题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA11424 GCD - Extreme (I) */#include <bits/stdc++.h>using namespace std;/* 欧拉函数打表 */
const int N = 200001;
long long phi[N + 1];
void setphi()
{memset(phi, 0, sizeof(phi));phi[1] = 1;for(int i = 2; i <= N; i++)if(phi[i] == 0)for(int j = i; j <= N; j += i) {if(phi[j] == 0) phi[j] = j;phi[j] = phi[j] / i * (i - 1);}
}long long f[N], s[N];void init()
{memset(f, 0, sizeof f);for (int i = 1; i < N; i++)for (int j = 2 * i; j < N; j += i)f[j] += i * phi[j / i];s[2] = f[2];for (int i = 3; i < N; i++)s[i] = s[i - 1] + f[i];
}int main()
{setphi();init();int n;while (~scanf("%d", &n) && n)printf("%lld\n", s[n]);return 0;
}

UVA11424 GCD - Extreme (I)【欧拉函数打表】相关推荐

  1. GCD - Extreme(欧拉函数变形)

    题目链接:https://vjudge.net/problem/UVA-11426 题目大意: 给出整数n∈[2,4000000],求解∑gcd(i,j),其中(i,j)满足1≤i<j≤n. 的 ...

  2. UVA10990 Another New Function【欧拉函数打表】

    The depth of phi value of a number is denoted by the number of steps required before it reaches 1. A ...

  3. 数论 GCD 最大公约数 欧拉函数经典题 洛谷 CF1295D Same GCDs Codeforces1295D

    ​前言 两个月了,我终于更了-- 这两个月忙(chen)于(mi)内(xiang)卷(le),现在终于出新文章啦,(也算兑现了当初的出数论题文章的承诺)~ 不说废话了,今天给大家介绍一道CF/洛谷上的 ...

  4. 欧拉函数/欧拉函数打表 lightoj1370(java/c++ )

    例题 欧拉函数/素数判定 题目链接 题目 Bamboo Pole-vault是Xzhiland的一项大受欢迎的运动. Phi-shoe大师是他成功的非常受欢迎的教练.他需要为他的学生提供一些竹子,所以 ...

  5. 杭电多校第十场 hdu6434 Count 欧拉函数打表 快速打表模板

    Problem I. Count Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Other ...

  6. UVA11426 GCD - Extreme (II)【欧拉函数】

    Given the value of N, you will have to find the value of G. The definition of G is given below: G=∑i ...

  7. POJ 2480 (约数+欧拉函数)

    题目链接: http://poj.org/problem?id=2480 题目大意:求Σgcd(i,n). 解题思路: 如果i与n互质,gcd(i,n)=1,且总和=欧拉函数phi(n). 如果i与n ...

  8. poj2154Color polya定理+欧拉函数优化

    没想到贱贱的数据居然是错的..搞得我调了一中午+晚上一小时(哦不d飞LJH掉RP毕竟他是BUFF)结果重判就对了五次.. 回归正题,这题傻子都看得出是polya定理(如果你不是傻子就看这里),还没有翻 ...

  9. 欧拉函数+狄利克雷卷积+莫比乌斯函数+莫比乌斯反演+整除分块+杜教筛

    Powered by:NEFU AB-IN 文章目录 欧拉函数 狄利克雷卷积 莫比乌斯函数 莫比乌斯反演 P3455 [POI2007]ZAP-Queries 整除分块 P2522 [HAOI2011 ...

最新文章

  1. jquery的html代码中a的onclick的正确显示的代码
  2. 【火爆】微软的Holographic会给我们带来什么?Imagine porn with this...
  3. static 变量初始化顺序的问题和解决方案
  4. 一篇文章彻底明白Hive数据存储的各种模式
  5. 回调 that.setdata 数据不更新_重大利空落地,或损上亿利润,乐普医疗回调近四成...
  6. acc定义代码 神经网络_神经网络的这几个坑,你都躲过了吗
  7. 使用 Python 解数学方程
  8. 已知: 每个飞机只有一个油箱, 飞机之间可以相互加油(注意是相互,没有加油机) 一箱油可供一架飞机绕地球飞半圈,问题:为使至少一架飞机绕地球一圈回到起飞时的飞机...
  9. 【先定一个小目标】Asp.net Core 在IIS上的托管运行
  10. ROS配置环境搞错了,每次开终端都有bash: export: `/home/yyq/ork_ws/devel/setup.bash‘: 不是有效的标识符
  11. cad看图软件看图软件哪个好?
  12. KEIL MDK中 warning: #223-D: function “xxx“ declared implicitly 解决方法
  13. Zabbix监控网站
  14. 我裂了,换领导后,竟然每天都要写日报
  15. 安全牛联合世平信息共同发布《数据防泄密 (DLP) 业务应用指南》
  16. 活动回顾|Apache Doris 向量化技术实现与后续规划
  17. Windows 环境配置Github 的SSH key
  18. mac环境搭建node.js并启服务
  19. 从零开始的MySQL教程——上
  20. 超像素分割(Superpixel Segmentation)发展

热门文章

  1. util包的简单介绍
  2. JavaWeb——web.xml配置详细解读
  3. Spring.Net配置多数据源
  4. golang 使用 consul 做服务发现
  5. Fission:基于 Kubernetes 的 Serverless 函数框架
  6. PHP异步调用实现方式
  7. 在Linux集群上部署Spark之前准备
  8. excel导入成html页面上的表格
  9. java consumer.poll_java – 无法在kafka consumer下设置’max.poll.records’,其中cons.poll仍然返回分区下的所有记录...
  10. python爬虫大作业爬多少数据_爬虫大作业