Pagini recente » Cod sursa (job #3280228) | Cod sursa (job #2264687) | Cod sursa (job #2397012) | Clasament qwegqe | Cod sursa (job #193439)
Cod sursa(job #193439)
#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;
}
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;
}