Pagini recente » Cod sursa (job #2215209) | Cod sursa (job #334560) | Cod sursa (job #1667585) | Cod sursa (job #104050) | Cod sursa (job #877975)
Cod sursa(job #877975)
#include <fstream>
using namespace std;
#define inf 100001
int e[inf];
ifstream in("sum.in");
ofstream out("sum.out");
int main()
{
int n, i, j, k;
for(i=1;i<=inf;i++)
e[i]=i;
for(i=2;i<=inf;i++)
if(e[i]==i)
for(j=i;j<=inf;j+=i)
e[j]=e[j]/i*(i-1);
in >> n;
for(i=1;i<=n;i++)
{
in >> k;
out << (long long)e[k]*2*k;
out << "\n";
}
in.close();
out.close();
return 0;
}