Cod sursa(job #1632165)
Utilizator | Data | 5 martie 2016 22:12:17 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include <fstream>
#include <string.h>
using namespace std;
ofstream fout("fractii.out");
ifstream fin("fractii.in");
int n,suma,s[1000005];
long long nrmax;
int main()
{
fin>>n;
s[1]=1;
for(int i=2;i<=n;i++) s[i]=i-1;
for(int i=2;i<=n;i++)
{
nrmax+=s[i];
for(int j=2*i;j<=n;j+=i) s[j]-=s[i];
}
fout<<2*nrmax+1;
}