Cod sursa(job #2933054)

Utilizator staicumateiStaicu Matei Octavian staicumatei Data 4 noiembrie 2022 15:59:35
Problema Sum Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.43 kb
#include<bits/stdc++.h>

using namespace std;

ifstream f("sum.in");
ofstream g("sum.out");

int i,j,n,x,e[100002];

int main()
{
    f>>n;
    for(i=2; i<100002; i++)
        e[i]=i;
    for(i=2; i<100002; i++)
        if(e[i]==i)
            for(j=i; j<100002; j=j+i)
                e[j]=e[j]/i*(i-1);
    for(i=1; i<=n; i++)
    {
        f>>x;
        g<<(long long)e[x]*2*x<<endl;

    }
    return 0;
}