Cod sursa(job #219818)

Utilizator Bit_MasterAlexandru-Iancu Caragicu Bit_Master Data 8 noiembrie 2008 12:36:15
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <stdio.h>  
#include <math.h>  
int n,nr,i,j,k;            
bool gasit;          
int main()            
{  
    freopen("fractii.in","r",stdin);            
    freopen("fractii.out","w",stdout);            
    scanf("%d",&n);            
    for (i = 2; i <= (n-1); i++)            
        for (j = i + 1; j <= n; j++)            
        {          
			gasit = false;          
			if ((i%2!=0) || (j%2!=0))        
			{          
				if (j%i == 0)      
                    gasit = true;        
                else for (k = 3; k <= (j/2); k+=2)          
			  		    if ((i%k == 0) && (j%k == 0))          
							{          
								gasit = true;          
								break;          
							}          
						else {}
            }          
            else gasit = true;          
            if (!gasit)          
				nr++;          
		}     
    nr = nr * 2 + n * 2 - 1;    
    printf("%d",nr);            
    return 0;            
}