Cod sursa(job #1656128)
Utilizator | Data | 18 martie 2016 19:36:14 | |
---|---|---|---|
Problema | Frac | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<fstream>
using namespace std;
ifstream cin("frac.in");
ofstream cout("frac.out");
long long n,p;
bool cmmdc(long long a,long long b){
while(a!=b){
if(a>b)a-=b;
else b-=a;
}
if(a==1)return 1;
return 0;
}
int main(){
cin>>n>>p;
long long aux=0,rs=0;
bool t=true;
while(t){
aux++;
if(cmmdc(aux,n)){
rs++;
}
if(rs==p){cout<<aux;t=0;}
}
}