I-Honor GuardTime
limit:10000MS
Memory Limit:265216KB
64bit IO Format:%lld &%llu SubmitStatus
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
#include <iostream> #include <cstdio> #include <string> #include <cstring> #include <cmath > #include <sstream> #define N 50900using namespace Std;typedef long long ll;int vis[n],pri[n];int cnt;void init () {cnt=0; for (int i=2;i<=n;i++) {if (vis[i]==0) pri[cnt++]=i; for (int j=0;j<cnt && i*pri[j]<n;j++) {vis[i*pri[j]]=1; if (i%pri[j]==0) break; }}}int Main () {int n; Init (); while (~SCANF ("%d", &n)) {if (n==1) {puts ("1"); Continue }//for (int i=0;i<100;i++)//cout<<pri[i]<< ""; int num; int ans=0; for (int i=1;i<n;i++)//n Euler function {num=i; for (int j=0;j<cnt && pri[j]<=40009;j++) if (i%pri[j]==0) num=num* (pri[j]-1)/pri[j]; cout<< "num=" <<num<<endl; Ans+=num; } printf ("%d\n", ans*2+1); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The guard of Honor asks for the value of Euler function within n