Pagini recente » Cod sursa (job #2530721) | Cod sursa (job #1912502) | Cod sursa (job #569179) | Cod sursa (job #320385) | Cod sursa (job #1589411)
#include <fstream>
#include <array>
#include <numeric>
using namespace std;
constexpr int maxx = 100010;
int main(){
array<int, maxx> buf = {};
iota(begin(buf), end(buf), -1);
for(int i = 2; i < maxx; ++i){
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; }