Cod sursa(job #2268006)
Utilizator | Data | 24 octombrie 2018 14:07:18 | |
---|---|---|---|
Problema | Sum | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <cstdio>
using namespace std;
int cmmdc(int a,int b)
{
int r;
while(b)
{
r=a%b;
a=b;
b=r;
}
return a;
}
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
int n,i,x,j;
long long s;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
s=0;
scanf("%d",&x);
for(j=1;j<=x;j++)
{
if(cmmdc(j,x)==1)
s=s+j+2*x-j;
}
printf("%lld\n",s);
}
return 0;
}