Created
June 9, 2012 07:23
-
-
Save anonymous/2899967 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unordered_map> | |
#include <iostream> | |
using namespace std; | |
#define N 1000000 | |
int phi (int n) { | |
int result = n; | |
for (int i=2; i*i<=n; ++i) | |
if (n % i == 0) { | |
while (n % i == 0) | |
n /= i; | |
result -= result / i; | |
} | |
if (n > 1) | |
result -= result / n; | |
return result; | |
} | |
//алгоритм "решето Эратосфена" | |
unsigned int a[N]; | |
int main(){ | |
//заполним все ячейки числами по порядку: 0,1,2,3... | |
int z; | |
long long q = 0; | |
for (int i = 2; i <= N; ++i) | |
{ | |
q += phi(i); | |
} | |
cout << endl << q << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment