Cod sursa(job #1380385)

Utilizator bogdanciurezubogdan ciurezu bogdanciurezu Data 7 martie 2015 17:36:04
Problema Sum Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>
#define nmax 100050

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(i = 1; i <= nmax; ++i) v[i] = i - 1;

        for(i = 2; i <= nmax; ++i)
            for(j = i * 2; j <= nmax; j += i)
                v[j] -= v[i];
    for(z = 1; z <= N; ++z){
        f>>x;
        g<<2 * x * v[x]<<'\n';
    }
    return 0;
}