Cod sursa(job #2130847)
| Utilizator | Data | 13 februarie 2018 22:58:50 | |
|---|---|---|---|
| Problema | Fractii | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int v[1000005];
int n;
unsigned long long sol;
int main(){
fin >> n;
for(int i = 1; i <= n; i++)
v[i] = i-1;
for(int i = 2; i <= n; i++)
for(int j = 2*i; j <= n; j += i)
v[j] -= v[i];
for(int i=1;i<=n;i++){
cout << v[i]<<endl;
sol += v[i];
}
sol = 2 * sol + 1;
fout << sol;
return 0;
}
