Cod sursa(job #615214)
Utilizator | Szasz Tamas Csaba DDeidara | Data | 8 octombrie 2011 21:56:23 |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <fstream>
using namespace std;
int lnko(unsigned long a,unsigned long b);
int main()
{
unsigned long n,i,j,sum = 0;
ifstream f("fractii.in");
ofstream g("fractii.out");
f>>n;
f.close ();
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
if ( lnko(i,j) == 1 )
sum ++;
g<<sum*2+1;
g.close();
return 0;
}
int lnko(unsigned long a,unsigned long b)
{
if (!b) return a;
return lnko(b, a % b);
}