Cod sursa(job #83800)
| Utilizator | Data | 11 septembrie 2007 22:26:44 | |
|---|---|---|---|
| Problema | Frac | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include<stdio.h>
long long unsigned n, p;
int prim(long long unsigned x,long long unsigned y)
{
while (x!=y)
{
if (x>y) x=x-y;
else y-=x;
}
if (x==1) return 1;
return 0;
}
void calcul()
{
long long nr, contor=0;
freopen("frac.in","r",stdin);
scanf("%llu%llu",&n,&p);
nr=0;
while (contor<p)
{
nr++;
if (n%2==0 && nr%2==0);
else if (prim(n,nr)) contor++;
}
freopen("frac.out","w",stdout);
printf("%llu",nr);
}
int main()
{
calcul();
return 0;
}
