Pagini recente » Cod sursa (job #2786780) | Cod sursa (job #903849) | Cod sursa (job #1092521) | Cod sursa (job #1754126) | Cod sursa (job #1589412)
#include <fstream>
#include <array>
#include <numeric>
using namespace std;
constexpr int maxx = 100010;
int main(){
array<long long, 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(long long i = 0, x; i < n; ++i){
f >> x;
g << 2ll * x * buf[x] << '\n'; }
return 0; }