Cod sursa(job #2592368)

Utilizator darkeagleDaniel Popescu darkeagle Data 1 aprilie 2020 17:05:18
Problema Sum Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <iostream>
#include <cstdio>
#define nmax 100001
using namespace std;
FILE * f = fopen("sum.in", "r");
FILE * g = fopen("sum.out", "w");
int n;
int phi[nmax],phi1[nmax];
int main() {
    int i, j, x;
    fscanf(f,"%d",&n);
    phi[1] = 0;  
     
    for(i=2;i<=nmax;i++) {
        phi[i] = i-1;
         
    }
    for(i=2 ;i <= nmax; i++) {
        for(j = 2*i;j <= nmax;j += i) {
            phi[j] -= phi[i];
             

        }
    }
    int t;
    for(i = 1;i <= n-1;i++) {
        fscanf(f,"%d",&x);
        t = x * phi[x] *2;
        fprintf(g,"%d\n",t);
    }   
    fscanf(f,"%d",&x);
        t = x * phi[x] *2;
        fprintf(g,"%d\n",t); 
    fclose(f);
    fclose(g);

    return 0;

}