1 Long LongEuler_phi (intN)2 {3 intM= (int) sqrt (n+0.5);4 intans=N;5 for(intI=2; i<=m;i++)6 7 if(n%i==0)8 {9ans=ans/i* (I-1);Ten while(n%i==0) OneN/=i; A } - if(n>1) ans=ans/n* (n1); - returnans; the}
Description
As a sports Commissioner, C June is responsible for the training of the honor guard. Guard of Honor is composed of students of N * N of the square, in order to ensure that the procession uniform, c June will follow the guard of Honor's left rear, according to the number of students in the line of sight to determine whether the team is neat (such as). Now, C-June wants you to tell him the number of students you can see when the team is neat.
Input
A total of a number n.
Output
A total of a number, that is, c June should see the number of students.
Sample Input
4
Sample Output
9
Hint
"Data size and conventions" for 100% of data, 1≤n≤40000
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <algorithm>5#include <cmath>6#include <sstream>7#include <string>8 using namespacestd;9 Long LongEuler_phi (intN)Ten { One intM= (int) sqrt (n+0.5); A intans=N; - for(intI=2; i<=m;i++) - the if(n%i==0) - { -ans=ans/i* (I-1); - while(n%i==0) +N/=i; - } + if(n>1) ans=ans/n* (n1); A returnans; at } - - intMain () - { - intN; - Long Longsum=0; inscanf"%d",&n); - for(intI=1; i<n;i++) tosum+=Euler_phi (i); +sum=sum*2+1; -printf"%lld\n", sum); the return 0; *}
Honor Guard (Euler function template)