Cod sursa(job #2012115)

Utilizator sandupetrascoPetrasco Sandu sandupetrasco Data 17 august 2017 22:18:31
Problema Sum Scor 95
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define oo 1000000000
#define PII pair <int, int>
  
using namespace std;

int n, tab[200100], x;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    freopen("sum.in","r",stdin);
    freopen("sum.out","w",stdout);
    scanf("%i", &n);
	for (int i = 1; i <= 100000; i++) tab[i] = i - 1;
	for (int i = 2; i <= 100000; i++)
		for (int j = i + i; j <= 100000; j += i)
			tab[j] -= tab[i];
    while (n--){
		scanf("%i", &x);
		ll rs = 2LL * x * tab[x];
		cout << rs << "\n";
	}
}