Pagini recente » Cod sursa (job #2000529) | Cod sursa (job #1928973) | Cod sursa (job #2598974) | Cod sursa (job #2801460) | Cod sursa (job #357573)
Cod sursa(job #357573)
Utilizator |
Marian S eu93 |
Data |
19 octombrie 2009 20:09:01 |
Problema |
Fractii |
Scor |
10 |
Compilator |
cpp |
Status |
done |
Runda |
CNRV #3 |
Marime |
0.44 kb |
#include <fstream.h>
#include <math.h>
int main()
{ long n,i,j,k=1,ok,l,max;
ifstream f("fractii.in");
ofstream g("fractii.out");
f>>n; k=n;
for (i=2;i<=n;i++)
for (j=1;j<=n;j++){
if (i!=j) {ok=1;
if (i%2==0 && j%2==0) ok=0;
if (ok==1) {
if (i>j) max=i;
else max=j;
for (l=3;l<=max/2 && ok==1;l+=2) if (i%l==0 && j%l==0) ok=0;
}
if (ok==1) k++;
}
}
g<<k;
f.close();
g.close();
return 0;
}