Cod sursa(job #1589415)
| Utilizator | Data | 3 februarie 2016 22:58:16 | |
|---|---|---|---|
| Problema | Sum | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#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; }
