Cod sursa(job #591432)
Utilizator | Lup Ionut rudarel | Data | 24 mai 2011 10:21:00 |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.67 kb |
using namespace std;
#include <fstream>
long int euclid(long int a, long int b)
{
long int c;
while(b)
{
c = a % b;
a = b;
b = c;
}
return a;
}
int main()
{
long int n = 0, m = 0, i = 0, j = 0;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
fin >> n;
for (i = 2; i <= n; i++)
for (j = i + 1; j <= n; j++)
if (euclid(i, j) == 1) m++;
m = m * 2;
m += n + n - 1;
fout << m << "\n";
fin.close();
fout.close();
return 0;
}