Cod sursa(job #875882)
| Utilizator | Data | 10 februarie 2013 21:25:45 | |
|---|---|---|---|
| Problema | Fractii | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<stdio.h>
long o,n;
long cmmdc(long x, long y)
{ while(x!=y)
if(x>y)
x=x-y;
else
y=y-x;
return x;
}
int main()
{
FILE *f;
f=fopen("fractii.in","rt");
fscanf(f, "%d", &n);
fclose(f);
for(int i=2;i<=n;i++)
for(int j=i+1;j<=n;j++)
if(cmmdc(i,j)==1)
o++;
f=fopen("fractii.out","wt");
fprintf(f,"%d", o+o+n+n-1);
fclose(f);
return 0;
}
