Cod sursa(job #2126019)

Utilizator Baba_DorinBaba Dorin Baba_Dorin Data 8 februarie 2018 23:07:42
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <iostream>
#include <fstream>
#include <limits.h>
using namespace std;
 
ifstream f("fractii.in");
ofstream g("fractii.out");
 
int n, phi[1000001];
 
void indicatorulLuiEuler(int 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];
}
 
void fractii(int n){
 
long long s=0;
 
indicatorulLuiEuler(n);
for(int i=2; i<=n; i++)
    s+=phi[i];
g<<s*2+1;
 
}
 
int main()
{
 
f>>n;
fractii(n);
    return 0;
}