Pagini recente » Cod sursa (job #422792) | Cod sursa (job #1284598) | Cod sursa (job #1839625) | Profil Patricia26 | Cod sursa (job #2271053)
#include <bits/stdc++.h>
using namespace std ;
ifstream fin("fractii.in") ;
ofstream fout("fractii.out") ;
int My_CMMDC(int a, int b)
{
if( a == b or a == 0 or b == 0 )
{
if(a > b)
return a ;
else
return b ;
}
else
{
if(a % 2 == 0)
{
if(b % 2 == 0)
return 2 * My_CMMDC(a / 2, b / 2) ;
else
return My_CMMDC(a / 2, b) ;
}
else
{
if(b % 2 == 0)
return My_CMMDC(a, b / 2) ;
else
{
if(a < b)
return My_CMMDC(a, (b - a) / 2) ;
else
return My_CMMDC((a - b) / 2, b) ;
}
}
}
}
int main()
{
ios_base::sync_with_stdio(false) ;
cin.tie(NULL) ;
int n ;
fin >> n ;
int nr = 0 ;
for(int i = 1 ; i <= n ; i += 1)
for(int j = i ; j <= n ; j += 1)
{
if(i != j)
{
if(My_CMMDC(i , j) == 1)
nr += 2 ;
}
}
fout << nr + 1 ;
return 0 ;
}