Pagini recente » Cod sursa (job #1005267) | Cod sursa (job #1843091) | Cod sursa (job #1615820) | Cod sursa (job #1551026) | Cod sursa (job #572054)
Cod sursa(job #572054)
# include <fstream>
# define xmax 100005
using namespace std;
ifstream f ("sum.in");
ofstream g ("sum.out");
int p[xmax+100],i,j,n,x;
long long int s;
int main ()
{
f>>n;
for (i=1;i<=xmax;i++)
p[i]=i;
for (i=2;i<=xmax;i++)
if (p[i]==i)
for (j=i;j<=xmax;j+=i)
p[j]=p[j]-p[j]/i;
for (i=1;i<=n;i++)
{
f>>x;
s=(long long)2*p[x]*x;
g<<s<<"\n";
}
return 0;
}