Cod sursa(job #193437)

Utilizator carloneIoan-Carol Plangu carlone Data 4 iunie 2008 15:59:33
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include"stdio.h"
#include"stdint.h"
#include <cstdlib>
long x;
long out;
struct nod
{
       int n;nod *next;
};nod *a,*b,*c;
int cmmdc(int_fast32_t x,const int_fast32_t y)
{
    if(y){x%=y;return cmmdc(y,x);}
    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;
}