Cod sursa(job #3323645)

Utilizator blidar_lucianLuciannk blidar_lucian Data 18 noiembrie 2025 22:08:31
Problema Sum Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("sum.in");
ofstream g("sum.out");
const int MAXX = 100000;
int phi[MAXX + 1];

int main() {
    for (int i = 1; i <= MAXX; i++) phi[i] = i;
    for (int i = 2; i <= MAXX; i++) {
        if (phi[i] == i) {
            for (int j = i; j <= MAXX; j += i)
                phi[j] -= phi[j] / i;
        }
    }

    int N;
    f >> N;
    while (N--) {
        int X;
        f >> X;
        g << 1LL * X * phi[X] << "\n";
    }

    return 0;
}