Cod sursa(job #1216423)

Utilizator forever16Alex M forever16 Data 4 august 2014 16:12:11
Problema Sum Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <fstream>
#include <stdio.h>
#define max 100001

using namespace std;

    long long phi[max];
    int n, x;

int main()
{
    ifstream f("sum.in");
    freopen("sum.out", "w", stdout);

    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];

    f>>n;
        while (n--) {
            f>>x;
        long long s; s=2*x*phi[x];
            printf("%lld\n",s);
    }
    return 0;
}