Cod sursa(job #395259)
Utilizator | Data | 12 februarie 2010 17:30:37 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include<iostream.h>
#include<fstream.h>
int main()
{long P,Q,N,T,D,C;
int R;
fstream f("fractii.in",ios::in),g("fractii.out",ios::out);
f>>N;
P=2;
Q=1;
T=N;
R=1;
while (P<=N)
{if (Q>P)
C=Q;
else
C=P;
for (D=2;D<=C;D++)
{if (Q%D==0)
{if (P%D==0)
{R=3;
D=C;
}
}
}
if (R==1)
T=T+1;
R=1;
Q=Q+1;
if (Q>N)
{P=P+1;
Q=1;
}
}
g<<T;
}