#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int gcd(int a,int b){
if(!a)
return b;
return gcd(b%a,a);
}
int main(){
ios::sync_with_stdio(0);
int n,k;
while(cin>>n>>k){
vector<pair<int,int>> a;
a.push_back({1,1});
for(int i=1;i<=n;i++)
for(int j=1;j<i;j++)
if(gcd(j,i)==1)
a.push_back({j,i});
sort(a.begin(),a.end(),[](const pair<int,int> &a,const pair<int,int> &b){
double x=a.first,y=b.first;
x/=a.second,y/=b.second;
return x<y;
});
cout<<a[k-1].first<<'/'<<a[k-1].second<<endl;
}
}
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int gcd(int a,int b){
if(!a)
return b;
return gcd(b%a,a);
}
int main(){
ios::sync_with_stdio(0);
int n,k;
while(cin>>n>>k){
vector<pair<int,int>> a;
a.push_back({1,1});
for(int i=1;i<=n;i++)
for(int j=1;j<i;j++)
if(gcd(j,i)==1)
a.push_back({j,i});
sort(a.begin(),a.end(),[](const pair<int,int> &a,const pair<int,int> &b){
double x=a.first,y=b.first;
x/=a.second,y/=b.second;
return x<y;
});
cout<<a[k-1].first<<'/'<<a[k-1].second<<endl;
}
}
Comments
Post a Comment