//author Eterna
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<complex>
#include<numeric>
#include<unordered_map>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define Pi acos(-1.0)
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x & -x)
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1e6;
const int INF = 0x7fffffff;
const int mod = 1e9 + ;
const double eps = 1e-;
inline int read_int() {
char c;
int ret = , sgn = ;
do { c = getchar(); } while ((c < '' || c > '') && c != '-');
if (c == '-') sgn = -; else ret = c - '';
while ((c = getchar()) >= '' && c <= '') ret = ret * + (c - '');
return sgn * ret;
}
inline ll read_ll() {
char c;
ll ret = , sgn = ;
do { c = getchar(); } while ((c < '' || c > '') && c != '-');
if (c == '-') sgn = -; else ret = c - '';
while ((c = getchar()) >= '' && c <= '') ret = ret * + (c - '');
return sgn * ret;
}
int phi[maxn + ], prime[maxn + ];
ll sum[maxn + ];
bool is_prime[maxn + ];
void init(int n, int cnt = ) {
for (int i = ; i <= n; ++i)is_prime[i] = true;
for (int i = ; i <= n; ++i) {
if (is_prime[i])prime[++cnt] = i, phi[i] = i - ;
for (int j = ; j <= cnt && i * prime[j] <= n; ++j) {
is_prime[i * prime[j]] = false;
if (i % prime[j])phi[i * prime[j]] = phi[i] * phi[prime[j]];
else {
phi[i * prime[j]] = phi[i] * prime[j];
break;
}
}
}
for (int i = ; i <= n; ++i)for (int j = ; j * i <= n; ++j)sum[i * j] += i * phi[j];
for (int i = ; i <= n; ++i)sum[i] += sum[i - ];
}
int n;
int main()
{
init(maxn);
while (n = read_int())printf("%lld\n", sum[n]);
//system("pause");
return ;
}

SP3871 GCDEX - GCD Extreme的更多相关文章

  1. 洛谷 - SP3871 GCDEX - GCD Extreme - 莫比乌斯反演

    易得 $\sum\limits_{g=1}^{n} g \sum\limits_{k=1}^{n} \mu(k) \lfloor\frac{n}{gk}\rfloor \lfloor\frac{n}{ ...

  2. spoj 3871. GCD Extreme 欧拉+积性函数

    3871. GCD Extreme Problem code: GCDEX Given the value of N, you will have to find the value of G. Th ...

  3. UVA 11426 GCD - Extreme (II) (欧拉函数)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Problem JGCD Extreme (II)Input: Standard ...

  4. UVA 11426 - GCD - Extreme (II) (数论)

    UVA 11426 - GCD - Extreme (II) 题目链接 题意:给定N.求∑i<=ni=1∑j<nj=1gcd(i,j)的值. 思路:lrj白书上的例题,设f(n) = gc ...

  5. 【UVa11426】GCD - Extreme (II)(莫比乌斯反演)

    [UVa11426]GCD - Extreme (II)(莫比乌斯反演) 题面 Vjudge 题解 这.. 直接套路的莫比乌斯反演 我连式子都不想写了 默认推到这里把.. 然后把\(ans\)写一下 ...

  6. UVA11426 GCD - Extreme (II) (欧拉函数/莫比乌斯反演)

    UVA11426 GCD - Extreme (II) 题目描述 PDF 输入输出格式 输入格式: 输出格式: 输入输出样例 输入样例#1: 10 100 200000 0 输出样例#1: 67 13 ...

  7. GCD - Extreme (II) for(i=1;i<N;i++) for(j=i+1;j<=N;j++) { G+=gcd(i,j); } 推导分析+欧拉函数

    /** 题目:GCD - Extreme (II) 链接:https://vjudge.net/contest/154246#problem/O 题意: for(i=1;i<N;i++) for ...

  8. USACO GCD Extreme(II)

    题目大意:求gcd(1,2)+gcd(1,3)+gcd(2,3)+...+gcd(n-1,n) ---------------------------------------------------- ...

  9. UVA 11424 GCD - Extreme (I) (欧拉函数+筛法)

    题目:给出n,求gcd(1,2)+gcd(1,3)+gcd(2,3)+gcd(1,4)+gcd(2,4)+gcd(3,4)+...+gcd(1,n)+gcd(2,n)+...+gcd(n-1,n) 此 ...

随机推荐

  1. 结对编程ending-我和洧洧的碎碎念

    应该是第一次和队友分工合作去完成一个项目,其中也经历了跳进不少坑又被拉回来的过程,总体来说这对于我俩也的确是值得纪念的一次经历. 我的碎碎念时间…… 对比个人项目和结对编程项目二者需求,前者重在面对不 ...

  2. JAVA EE 的学习目标

    本学期是大三下学期,是一个很关键的学习期.在这里定下一个短期的目标. 职业发展目标:我的职业目标其实不是计算机方向,我是准备考公.但是,作为第二手专业打算,如果考公务员失败,我根据我的性格来分析我会选 ...

  3. python3.5+selenium3环境搭建

    windows环境下的操作(例子中的浏览器以火狐浏览器为例,IE和谷歌与此浏览器同理): 准备工具如下: 下载python[python开发环境]:http://python.org/getit/ 下 ...

  4. 常用MySQL操作(一)

    第二十四次课 常用MySQL操作(一) 目录 一.设置更改root密码 二.连接mysql 三.mysql常用命令 四.mysql用户管理 五.常用sql语句 六.mysql数据库备份恢复 七.扩展 ...

  5. C语法简单测试

    1.未初始化的枚举变量 /* uninitialized-enum.c */ #include <stdio.h> , black, blue}; int main(void) { enu ...

  6. vue 中生成二维码之爬坑之路

    最近在做vue中项目,有个需求是在你提交信息后把后台返给你的链接生成二维码. 一共使用了两种生成二维码的方法 1.vue-qr 这个是在一进入页面直接生成二维码,具体介绍见文档:https://www ...

  7. CSS中的颜色问题

    css颜色: CSS 颜色 颜色是通过对红.绿和蓝光的组合来显示的 颜色值 CSS 颜色使用组合了红绿蓝颜色值 (RGB) 的十六进制 (hex) 表示法进行定义.对光源进行设置的最低值可以是 0(十 ...

  8. 个人洛谷账号地址——https://www.luogu.org/space/show?uid=181909 附上NOIP查分系统

    个人洛谷地址:       https://www.luogu.org/space/show?uid=181909 NOPI查分地址:      http://bytew.net/OIer/

  9. 黑客常用dos-cmd命令

    黑客常用命令大全net user heibai lovechina /add 加一个heibai的用户密码为lovechina net localgroup Administrators heibai ...

  10. openSUSE XFCE桌面 多媒体解码器安装

    openSUSE15 leap 在终端命令行安装编解码器: 添加必要的软件源 zypper addrepo -f http://packman.inode.at/suse/openSUSE_Leap_ ...