Pagini recente » Cod sursa (job #3209952) | Cod sursa (job #2312760) | Cod sursa (job #2989055) | Cod sursa (job #2412025) | Cod sursa (job #134205)
Cod sursa(job #134205)
#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)
{
long long r;
while(a%b) { r=a%b; a=b; b=r; }
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;
}