Pagini recente » Cod sursa (job #2892465) | Cod sursa (job #2841561) | Cod sursa (job #1912559) | Cod sursa (job #7538) | Cod sursa (job #1589415)
#include <cstdio>
#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]; } }
FILE *f = fopen("sum.in", "r"), *g = fopen("sum.out", "w");
int n;
fscanf(f, "%d", &n);
for(int i = 0, x; i < n; ++i){
fscanf(f, "%d", &x);
fprintf(g, "%lld\n", (long long) (2*x) * (long long)buf[x]); }
fclose(f), fclose(g);
return 0; }