Cod sursa(job #1340133)

Utilizator WongravenWongraven Wongraven Data 11 februarie 2015 15:59:37
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include<fstream>
 
using namespace std;
typedef int64_t var;
 
ifstream fin("fractii.in");
ofstream fout("fractii.out");
 
var sum = 1;
var EULER[1000001];
 
void build_euler(var n) {
    for(var i=2; i<=n; i++) {
        EULER[i] = i;
    }
    for(var i=2; i<=n; i++) {
        if(EULER[i] == i) {
            for(var j=i; j<=n; j+=i) {
                EULER[j] = EULER[j] * (i-1)/i;
            }
        }
        sum += 2*EULER[i];
    }
}
 
 
int main() {
    var n;
    fin>>n;
    build_euler(n);
    fout<<sum;
    return 0;
}