Cod sursa(job #1123599)
Utilizator | Data | 26 februarie 2014 09:16:51 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n;
fin >> n;
int a[n + 2];
int i, j;
unsigned long long nrf;
for(i = 2; i <= n; i++)
a[i] = i - 1;
for(i = 2; i <= n; i++)
{
nrf += a[i];
for(j = 2 * i; j <= n;j += i)
a[j] -= a[i];
}
fout << nrf * 2 + 1;
return 0;
}