Cod sursa(job #2059496)

Utilizator PetcuDavidPetcu David PetcuDavid Data 7 noiembrie 2017 09:16:24
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include <iostream>
#include <fstream>
using namespace std;

float v[1000000];

float relprim(int x){
int d=2;
while(x%d!=0)
d++;
while(x%d==0)
x=x/d;
return v[x]*(d-1)/d;

}

int main(){
ifstream f("fractii.in"); ofstream g("fractii.out");
long long S=0;
v[1]=1;
int x; f>>x;
for(int i=2;i<=x;i++){
v[i]=0;
v[i]=relprim(i);
S=S+i*v[i];}
S=2*S+1;
g<<S;
return false;}