Cod sursa(job #1740399)
Utilizator | Data | 11 august 2016 15:57:16 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
//brut : O(N^2*log N)-cred
#include <fstream>
using namespace std ;
ifstream f ("fractii.in") ;
ofstream g ("fractii.out") ;
int N ;
int gcd ( int a , int b )
{
if ( b == 0 ) return a ;
a %= b ;
return gcd ( b , a ) ;
}
int main ()
{
f >> N ;
long long nr_total = N ;
for ( int i = 2 ; i <= N ; ++i )
for ( int j = 1 ; j <= N ; ++j )
if( gcd ( i , j ) == 1 )
++nr_total ;
g << nr_total ;
}