Cod sursa(job #1324602)

Utilizator A63N7pTudor Nazarie A63N7p Data 22 ianuarie 2015 16:11:18
Problema Sum Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.27 kb
/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <cstdio>
#include <cstdlib>
using namespace std;

int v[100111];

int main(int argc, char *argv[])
{
    freopen("sum.in", "r", stdin);
    freopen("sum.out", "w", stdout);

	int n;
    scanf("%d", &n);

    for(int i = 2; i <= 100001; i++) {
        v[i] = i;
    }
    for(int i = 2; i <= 100001; i++) {
        if(v[i] == i) {
            for(int j = i; j <= 100001; j += i) {
                v[j] = v[j] / i * (i - 1);
            }
        }
    }

    for(int i = 1; i <= n; i++) {
		int x;
        scanf("%d", &x);
        printf("%lld\n", (long long)2 * x * v[x]);
    }
    return 0;
}