Cod sursa(job #2703724)

Utilizator tomaionutIDorando tomaionut Data 9 februarie 2021 09:43:50
Problema Sum Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
int n,x,k;
int phi[100005];
int main()
{
    int i,j;
    fin >> k;
    for (i=1; i<=100000; i++)
        phi[i]=i-1;
    for (i=1; i<=100000; i++)
    {
        for (j=2*i; j<=100000; j+=i)
            phi[j]-=phi[i];

    }
    while (k--)
    {
        fin >> x;
        fout << 2*x*phi[x] << "\n";
    }
    return 0;
}