Pagini recente » Cod sursa (job #2302893) | Statistici Baciu Daniel Mihai (danibaciu) | Diferente pentru probleme-de-taietura intre reviziile 75 si 96 | Istoria paginii probleme-de-taietura | Cod sursa (job #2846476)
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n;
int v[1000001];
long long s;
int main()
{
fin >> n;
s = 1;
for (int i = 1; i <= n; i++)
v[i] = i;
for (int i = 1; i <= n; i++)
for (int j = i * 2; j <= n; j = j + i)
v[j] = v[j] - v[i];
for (int i = 2; i <= n; i++)
s = s + 2 * v[i];
fout << s;
}