Cod sursa(job #1117160)

Utilizator ionut98Bejenariu Ionut Daniel ionut98 Data 23 februarie 2014 10:11:24
Problema Frac Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include<fstream>
#include<cstdio>
using namespace std;
unsigned long long i,k,n;
int cmmdc(int a,int b)
{
    int r;
    while(b)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int main()
{
    freopen("frac.in","r",stdin);
    freopen("frac.out","w",stdout);
    scanf("%d", &n);
    scanf("%d", &k);
    while(k!=0)
    {
        i++;
        if(cmmdc(n,i)==1)
        k--;
    }
    printf("%d\n", i);
    return 0;
}