Cod sursa(job #2709638)
Utilizator | Data | 20 februarie 2021 19:44:36 | |
---|---|---|---|
Problema | Fractii | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
int n,v[1000001],i,j;
int main()
{
f>>n;
for(i=1;i<=n;i++)
v[i]=i;
for(i=2;i<=n;i++)
{
if(v[i]==i)
{
v[i]--;
for(j=i+i;j<=n;j+=i)
{
v[j]=v[j]*(i-1)/i;
}
}
}
for(i=2;i<=n;i++)
v[i]=v[i-1]+2*v[i];
g<<v[n];
return 0;
}