Cod sursa(job #1589408)

Utilizator tamionvTamio Vesa Nakajima tamionv Data 3 februarie 2016 22:50:54
Problema Sum Scor 95
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream>
#include <array>
using namespace std;

constexpr int maxx = 100010;

int main(){
	array<int, maxx> buf = {};
	for(int i = 1; i < maxx; ++i){
		buf[i] += i-1;
		for(int j = 2*i; j < maxx; j += i){
			buf[j] -= buf[i]; } }

	ifstream f("sum.in");
	ofstream g("sum.out");
	int n;
	f >> n;

	for(int i = 0, x; i < n; ++i){
		f >> x;
		g << (long long) (2*x) * (long long) buf[x] << '\n'; }
	return 0; }