Cod sursa(job #138750)

Utilizator VladimioDinu Vladimir Vladimio Data 19 februarie 2008 02:15:47
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include<iostream.h>
#include<stdio.h>
int main ()
{long int P=2,Q,N;
int contor,truth=1,truth2=3;
freopen ("fractii.in", "rt" ,stdin);
freopen ("fractii.out","wt" ,stdout);
scanf ("%ld", &N);
if (N==1) printf ("%d",truth);
else if (N==2) printf ("%d",truth2);
else {for (contor=2*N-1;P<=N;P++)
	  {Q=2;
	   while (Q<=N) {if (P%Q!=0) contor++;
			 else if (Q%P!=0) contor++;
			Q++;}}
printf ("%d",contor);}
return 0;}