Mai intai trebuie sa te autentifici.
Cod sursa(job #2003643)
| Utilizator | Data | 23 iulie 2017 15:01:19 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <fstream>
#define LL long long
#define MAX 1000000
using namespace std;
ifstream fi("fractii.in");
ofstream fo("fractii.out");
LL phi[MAX+5];
int n;
void getPhi()
{
for (int i=0; i<=n; i++)
phi[i]=i;
for (int i=2; i<=n; i++)
if (phi[i]==i)
for (int j=i; j<=n; j+=i)
phi[j]=phi[j]*(i-1)/i;
}
int main()
{
fi.sync_with_stdio(false);
fo.sync_with_stdio(false);
fi>>n;
getPhi();
LL rez=0;
for (int numarator=2; numarator<=n; numarator++)
rez+=phi[numarator];
rez=rez*2+1;
fo<<rez;
fi.close();
fo.close();
return 0;
}
