Cod sursa(job #134202)

Utilizator O_NealS. Alex O_Neal Data 10 februarie 2008 21:24:17
Problema Sum Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include<fstream.h>
ifstream fin("sum.in");
ofstream fout("sum.out");
long x,N,i,j;
long long s;

int cmmdc(long a, long b)

 {
              
              while(a!=b) { if(a>b) a-=b; else b-=a; }
              return b;
              
 }
 
int main()

 {  
    fin>>N;
    for(i=1; i<=N; i++)
       { fin>>x;
         s=0;
	     for(j=1; j<=2*x; j++)
                 if( !( ( x%2==0 && j%2==0 )||( x%10==5 && j%10==5)|| ( x%j==0&&j!=1 )||( j%x==0&&j!=1 ) ) ) if(cmmdc(j,x)==1) s+=j;  
         fout<<s<<"\n";
       }
    return 0;
 }