Cod sursa(job #1380382)

Utilizator bogdanciurezubogdan ciurezu bogdanciurezu Data 7 martie 2015 17:33:05
Problema Sum Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <fstream>
#define nmax 200050

using namespace std;
ifstream f("sum.in");
ofstream g("sum.out");
int N, x, desc[nmax / 10], v[nmax];
int main()
{int z, i, j;
    f>>N;
    for(z = 1; z <= N; ++z){
        f>>x;
        for(i = 1; i <= x; ++i) v[i] = i - 1;
        for(i = 2; i <= x; ++i)
            for(j = i * 2; j <= x; j += i)
                v[j] -= v[i];
        g<<2 * x * v[x]<<'\n';
    }
    return 0;
}