Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;
#define REP(i, j) for(double i = 0; i < j; i++)
#define FOR(i, j, k) for(double i = j; i < k; i++)
#define P pair<int, int>
#define PP pair<double, P>
 
int p, n;
vector<PP> v();
 
int gcd(int a, int b){
  if(b == 0) return a;
  else return gcd(b, a % b);
}
 
string make_r(int a, int b){
  int tmp = gcd(b, a);
  stringstream ss;
  ss <<a / tmp <<"/" <<b / tmp;
  return ss.str();
}
 
int main(){
  while(cin >>p >>n){
    if(p == 0 && n == 0) break;
    v = vector<PP>();
    REP(i, n + 1){
      REP(j, n + 1){
        v.push_back( PP(i / j, P(i, j)) );
        if(i / j < sqrt(p)) break;
      }
    }
    sort(v.begin(), v.end());
 
    int now = 1, max, min;
    while(v[now].first < sqrt(p)) now++;
    max = now;
    min = now - 1;
    cout <<make_r(v[max].second.first, v[max].second.second) <<" "
      <<make_r(v[min].second.first, v[min].second.second) <<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:7: error: assignment of function 'std::vector<std::pair<double, std::pair<int, int> > > v()'
   31 |     v = vector<PP>();
      |     ~~^~~~~~~~~~~~~~
a.cc:34:11: error: request for member 'push_back' in 'v', which is of non-class type 'std::vector<std::pair<double, std::pair<int, int> > >()'
   34 |         v.push_back( PP(i / j, P(i, j)) );
      |           ^~~~~~~~~
a.cc:38:12: error: request for member 'begin' in 'v', which is of non-class type 'std::vector<std::pair<double, std::pair<int, int> > >()'
   38 |     sort(v.begin(), v.end());
      |            ^~~~~
a.cc:38:23: error: request for member 'end' in 'v', which is of non-class type 'std::vector<std::pair<double, std::pair<int, int> > >()'
   38 |     sort(v.begin(), v.end());
      |                       ^~~
a.cc:41:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |     while(v[now].first < sqrt(p)) now++;
      |                ^
a.cc:41:18: error: request for member 'first' in '*(v + ((sizetype)now))', which is of non-class type 'std::vector<std::pair<double, std::pair<int, int> > >()'
   41 |     while(v[now].first < sqrt(p)) now++;
      |                  ^~~~~
a.cc:44:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   44 |     cout <<make_r(v[max].second.first, v[max].second.second) <<" "
      |                        ^
a.cc:44:26: error: request for member 'second' in '*(v + ((sizetype)max))', which is of non-class type 'std::vector<std::pair<double, std::pair<int, int> > >()'
   44 |     cout <<make_r(v[max].second.first, v[max].second.second) <<" "
      |                          ^~~~~~
a.cc:44:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   44 |     cout <<make_r(v[max].second.first, v[max].second.second) <<" "
      |                                             ^
a.cc:44:47: error: request for member 'second' in '*(v + ((sizetype)max))', which is of non-class type 'std::vector<std::pair<double, std::pair<int, int> > >()'
   44 |     cout <<make_r(v[max].second.first, v[max].second.second) <<" "
      |                                               ^~~~~~
a.cc:45:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |       <<make_r(v[min].second.first, v[min].second.second) <<endl;
      |                     ^
a.cc:45:23: error: request for member 'second' in '*(v + ((sizetype)min))', which is of non-class type 'std::vector<std::pair<double, std::pair<int, int> > >()'
   45 |       <<make_r(v[min].second.first, v[min].second.second) <<endl;
      |                       ^~~~~~
a.cc:45:42: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |       <<make_r(v[min].second.first, v[min].second.second) <<endl;
      |                                          ^
a.cc:45:44: error: request for member 'second' in '*(v + ((sizetype)min))', which is of non-class type 'std::vector<std::pair<double, std::pair<int, int> > >()'
   45 |       <<make_r(v[min].second.first, v[min].second.second) <<endl;
      |                                            ^~~~~~