Cod sursa(job #360085)
Utilizator | Data | 29 octombrie 2009 16:35:08 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <stdio.h>
void read(),solve();
long p,q,n,nr,a,b,r;
int main()
{
read();
solve();
return 0;
}
void read()
{
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
scanf("%d",&n);
}
void solve()
{
nr=0;
for (p=1;p<=n;p++)
for(q=1;q<=n;q++)
{
if (p>=q)
{
b=p;
a=q;
}else{
a=p;
b=q;
}
while(b!=0)
{
r=a%b;
a=b;
b=r;
}
if(a==1)
nr++;
a=0;
b=0;
}
printf("%d",nr);
}