Give an n, ask 1-n this n number, and the greatest common divisor of N. For example: n = 6

1,2,3,4,5,6 with 6 of the greatest common divisor respectively for 1,2,3,2,1,6, plus = 15

Input

1 number N (n <= 10^9)

OutPut

Sum of the number of conventions

Input example

6

Output example

15

AC Code:

`/** * @xiaoran 2 3 4 5 6 * 2 3 2 1 6 * 2 1, 2 2, one 3, one 6, note that the following values are the factor of N. * Now we just have to figure out the number of factors, * then the number of 1 is the number of n coprime, that is, the value of the Euler function K=phi (N/2), * for the number of n factor i K=phi (n/i), sum+=k*i, */#include <iostream>#include <cstdio>#include <map>#include <cstring>#include <string>#include <algorithm>#include <queue>#include <vector>#include <stack>#include <cstdlib>#include <cctype>#include <cmath>#include <ctime>#define LOCAL#define LL Long Longusing namespace STD; LL Phi (intN) {//Find Euler function if(n==1)return 1; LL ans=n;intK= (int)sqrt(n+0.5); for(intI=2; i<=k;i++) {if(n%i==0) {ans=ans* (i1)/I; } while(n%i==0) N/=i; }if(n>1) ans=ans* (n1)/n;returnAns;}intgcdintAintb) {intRif(b==0)returnA while(b) {r=a%b; A=b; B=r; }returnA;}intPK (intKintN) {ints=1; for(inti=k*2; i<n;i+=k) {//Calculate the number of K if(GCD (n,i) >k)Continue; s++; }returns;}intMain () {/* #ifdef LOCAL freopen ("Input.txt", "R", stdin); Freopen ("Output.txt", "w", stdout); #endif * / intN while(Cin>>n) {LL t1=clock ();intK= (int)sqrt(n+0.5); LL ans=n; for(intI=2; i<=k;i++) {if(n%i==0){//cout<<pk (i,n) << "" <<PK (n/i,n) <<endl;Ans+=phi (n/i) *i+ (n/i) *phi (i); }} ans+=phi (n);if(k*k==n) {Ans-=k*phi (k); }cout<<ans<<endl; LL T2=clock ();//cout<<t2-t1<<endl;}return 0;}`

51nod 1040 Greatest Common divisor (mathematics)