Mai intai trebuie sa te autentifici.
Cod sursa(job #3273117)
| Utilizator | Data | 1 februarie 2025 10:13:24 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | cex_8 | Marime | 0.62 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("fractii.in") ;
ofstream fout ("fractii.out") ;
long long n , i , j , a[1000005] ;
long long sum , nr ;
const int Max = 1e6 ;
int main()
{
fin >> n ;
for ( i = 1 ; i <= Max ; i ++ )
a[i] = i ;
for ( i = 2 ; i <= Max ; i ++ )
{
if ( a[i] == i )
{
a[i] -- ;
for ( int j = 2 ; j * i <= Max ; j ++ )
a[j*i] = a[j*i] / i * ( i - 1 ) ;
}
}
for ( i = 1 ; i <= n ; i ++ )
sum += a[i] ;
nr = n * n ;
fout << sum * 2 - 1 ;
return 0;
}
