Cod sursa(job #1216420)

Utilizator forever16Alex M forever16 Data 4 august 2014 16:04:38
Problema Sum Scor 85
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <fstream>
#define max 100001

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

int main()
{ long long phi[max];
    int n, x;
    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];
    g <<s <<"\n";
    }
    return 0;
}