Cod sursa(job #2132575)
| Utilizator | Data | 15 februarie 2018 21:10:17 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int phi[1000005];
long long suma(int n){
long long s = 1;
for(int i = 2; i <= n; i++)
phi[i] = i - 1;
for(int i = 2; i <= n; i++){
s += 2*phi[i];
for(int j = 2*i; j <= n; j += i)
phi[j] -= phi[i];
}
return s;
}
int main(){
int n;
fin >> n;
fout << suma(n);
}
