Mai intai trebuie sa te autentifici.
Cod sursa(job #1589411)
Utilizator | Data | 3 februarie 2016 22:53:42 | |
---|---|---|---|
Problema | Sum | Scor | 95 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#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; }