Mai intai trebuie sa te autentifici.
Cod sursa(job #2891311)
| Utilizator | Data | 18 aprilie 2022 07:58:41 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.69 kb |
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3F3F3F3F
using namespace std;
const string file = "fractii";
ifstream fin (file + ".in");
ofstream fout (file + ".out");
const int N_MAX = 1e6 + 1;
ll N ,rezult = 0;
int totient[N_MAX];
int main()
{
fin>>N; fin.close();
for(int i=1; i<=N; i++){
totient[i]=i;
}
for(int i=2; i<=N; i++)
{
if(totient[i]==i)
{
for(int j=i; j<=N; j+=i)
{
totient[j]-=totient[j]/i;
}
}
}
for(int i=2; i<=N; i++){
rezult += 2*totient[i];
}
rezult++;
fout<<rezult; fout.close(); //cout<<rezult;
}
