Pagini recente » Cod sursa (job #2763803) | Cod sursa (job #3271013) | Cod sursa (job #2118175) | Cod sursa (job #982122) | Cod sursa (job #193442)
Cod sursa(job #193442)
#include"stdio.h"
#include"stdint.h"
#include <cstdlib>
long x;
long out;
struct nod
{
int n;nod *next;
};nod *a,*b,*c;/*
int_fast32_t cmmdc(int_fast32_t x,int_fast32_t y)
{int b=0;
while(x&&y)
{
switch(b)
{
case 0: x%=y;break;
case 1: y%=x;break;
}
b=(b+1)%2;
}
if(x)return x;else return y;
}*/
long cmmdc(long x,const long y)
{
if(y)return cmmdc(y,x%y);
else return x;
}
int val(const int_fast32_t x,const int_fast32_t y)
{
if(!x||!y)return 0;
if(cmmdc(x,y)==1)return 1;
return 0;
}
int main()
{
freopen("fractii.out","w",stdout);
freopen("fractii.in","r",stdin);
scanf("%ld",&x);
for(int_fast32_t g=0;g<(x+1)*(x+1)-1;g++){out+=val(g%(x+1),(g+1)/(x+1));}
printf("%ld",out);
return 0;
}