Pagini recente » Cod sursa (job #3160987) | Cod sursa (job #698965) | Cod sursa (job #161741) | Cod sursa (job #1156783) | Cod sursa (job #572053)
Cod sursa(job #572053)
# 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=2*p[x]*x;
g<<s<<"\n";
}
return 0;
}