Cod sursa(job #2010252)

Utilizator refugiatBoni Daniel Stefan refugiat Data 12 august 2017 12:20:35
Problema Sum Scor 95
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <iostream>
#include <fstream>
#define MAX 100000
using namespace std;
ifstream si("sum.in");
ofstream so("sum.out");
int phi[MAX+5];
void calc()
{
    for(int i=1;i<=MAX;i++)
        phi[i]=i-1;
    for(int i=2; i<=MAX; i++)
        for(int j=2*i;j<=MAX;j+=i)
            phi[j]-=phi[i];
}
int main()
{
    int n;
    si>>n;
    calc();
    int x;
    while(n--)
    {
        si>>x;
        so<<2LL*phi[x]*x<<'\n';
    }
    return 0;
}