Cod sursa(job #191195)

Utilizator O_NealS. Alex O_Neal Data 25 mai 2008 16:57:55
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include<fstream.h>

ifstream fin("fractii.in");
ofstream fout("fractii.out");


                
int main()
 {
          unsigned long long n,i,j;
          unsigned int phi[1000001];
          fin>>n;
          
          for ( i = 1; i <= n; ++i)
              phi[i] = i-1;
          for ( i = 2; i <= n; ++i)
              for (j = 2*i; j <= n; j += i)
                phi[j] -= phi[i];
          j=0;
          for(i=1; i<=n; i++)
             j+=phi[i];
          fout<<j*2+1;     

 }