Cod sursa(job #1763594)
| Utilizator | Data | 24 septembrie 2016 14:33:14 | |
|---|---|---|---|
| Problema | Fractii | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int phi[1000000];
int main()
{
ifstream in("fractii.in");
ofstream out("fractii.out");
int n, total;
in>>n;
for (int i = 1; i <= n; i++)
phi[i] = i-1;
for (int i = 2; i <= n; i++)
for (int j = 2*i; j <= n; j += i)
phi[j] -= phi[i];
total = n;
for(int i = 2; i <= n; i++)
{
if(phi[i] == i-1)
total += n-1;
else
total += (n-1)-phi[i];
}
out << total;
return 0;
}
