Cod sursa(job #1757430)

Utilizator Rocamadour1497Alexandru Martiniuc Rocamadour1497 Data 15 septembrie 2016 00:17:09
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <fstream>

using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
int main()
{

   int n,phi[1000001],i;
   f>>n;
   for (int i = 1; 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] /= i;
                phi[j] *= (i - 1);
            }
   long long s=1;
   for(i=2;i<=n;i++) s+=phi[i];
   g<<2*s-1;
    return 0;
}