alexjercan/bugnet huggingface dataset:
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
#define M 100000
using namespace std;
bool prime[M];
void primeInit() {
  for (int i = 0; i < M; i++) {
    prime[i] = false;
  }
}
void p() {
  prime[2] = true;
  for (int i = 3; i < M; i++) {
    bool flag = false;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        flag = true;
        break;
      }
    }
    if (!flag)
      prime[i] = true;
  }
}
int main() {
  int m, a, b;
  primeInit();
  p();
  while (cin >> m >> a >> b && m != 0 || a != 0 || b != 0) {
    double ma = 0;
    int mp = 0;
    int mq = 0;
    for (int p = 2; p <= m / 2; p++) {
      if (!prime[p])
        continue;
      for (int q = 2; q <= m / p; q++) {
        if (!prime[q])
          continue;
        if (1.0 * p * q > ma && 1.0 * p * q <= m && (1.0 * p / q) <= 1 &&
            (1.0 * p / q) >= (a * 1.0 / b)) {
          ma = p * q;
          mp = p;
          mq = q;
        }
      }
    }

    cout << mp << " " << mq << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
#define M 100000
using namespace std;
bool prime[M];
void primeInit() {
  for (int i = 0; i < M; i++) {
    prime[i] = false;
  }
}
void p() {
  prime[2] = true;
  for (int i = 3; i < M; i++) {
    bool flag = false;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        flag = true;
        break;
      }
    }
    if (!flag)
      prime[i] = true;
  }
}
int main() {
  int m, a, b;
  primeInit();
  p();
  while (cin >> m >> a >> b && m != 0 || a != 0 || b != 0) {
    double ma = 0;
    int mp = 0;
    int mq = 0;
    for (int p = 2; p <= m / 2; p++) {
      if (!prime[p])
        continue;
      for (int q = 2; q <= m / 2; q++) {
        if (!prime[q])
          continue;
        if (1.0 * p * q > ma && 1.0 * p * q <= m && (1.0 * p / q) <= 1 &&
            (1.0 * p / q) >= (a * 1.0 / b)) {
          ma = p * q;
          mp = p;
          mq = q;
        }
      }
    }

    cout << mp << " " << mq << endl;
  }
  return 0;
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

bool isPrime(int x) {
  if (x <= 1)
    return false;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  vector<int> ps;
  for (int x = 2; x <= 50000; ++x) {
    if (isPrime(x))
      ps.push_back(x);
  }
  for (int m, a, b; cin >> m >> a >> b && (m | a | b);) {
    int p = 0, q = 0;
    for (int i = 0; i < ps.size(); ++i) {
      for (int j = i; j < ps.size() && ps[i] * ps[j] <= m; ++j) {
        if (ps[i] * ps[j] <= m && a * ps[j] <= b * ps[i] &&
            ps[i] * ps[j] > p * q) {
          p = ps[i];
          q = ps[j];
        }
      }
    }
    cout << p << " " << q << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

bool isPrime(int x) {
  if (x <= 1)
    return false;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  vector<int> ps;
  for (int x = 2; x <= 50000; ++x) {
    if (isPrime(x))
      ps.push_back(x);
  }
  for (int m, a, b; cin >> m >> a >> b && (m | a | b);) {
    int p = 0, q = 0;
    for (int i = 0; i < ps.size(); ++i) {
      for (int j = i; j < ps.size(); ++j) {
        if (ps[i] * ps[j] <= m && a * ps[j] <= b * ps[i] &&
            ps[i] * ps[j] > p * q) {
          p = ps[i];
          q = ps[j];
        }
      }
    }
    cout << p << " " << q << endl;
  }
  return 0;
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll)a); i < ((ll)n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  vector<bool> isp(100001, true);
  isp[0] = isp[1] = false;
  REP(i, 0, isp.size())
  if (isp[i]) for (ll j = i + i; j < isp.size(); j += i) isp[j] = false;
  vector<ll> prime;
  REP(i, 0, isp.size()) if (isp[i]) prime.push_back(i);

  ll M, A, B;
  while (cin >> M >> A >> B, M && A && B) {
    ll m = 0;
    ll ansp, ansq;
    for (ll q : prime) {
      ll pmax = min(q, M / q);
      ll pmin = (A * q + B - 1) / B;
      ll x = upper_bound(prime.begin(), prime.end(), pmax) - prime.begin() - 1;
      if (prime[x] >= pmin) {
        ll p = prime[x];
        if (m <= p * q && p * q <= M) {
          ansp = p;
          ansq = q;
          m = p * q;
        }
      }
    }
    cout << ansp << " " << ansq << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll)a); i < ((ll)n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  vector<bool> isp(100001, true);
  isp[0] = isp[1] = false;
  REP(i, 0, isp.size())
  if (isp[i]) for (ll j = i + i; j < isp.size(); j += i) isp[j] = false;
  vector<ll> prime;
  REP(i, 0, isp.size()) if (isp[i]) prime.push_back(i);

  ll M, A, B;
  while (cin >> M >> A >> B, M && A && B) {
    ll m = 0;
    ll ansp, ansq;
    for (ll q : prime) {
      ll pmax = q;
      ll pmin = (A * q + B - 1) / B;
      ll x = lower_bound(prime.begin(), prime.end(), pmin) - prime.begin();
      for (ll j = x; j < prime.size() && prime[j] <= pmax; j++) {
        ll p = prime[j];
        if (m <= p * q && p * q <= M) {
          ansp = p;
          ansq = q;
          m = p * q;
        }
      }
    }
    cout << ansp << " " << ansq << endl;
  }
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 100000
using namespace std;
bool isPrime(int x) {
  if (x < 2)
    return false;
  if (x == 2)
    return true;
  if (x % 2 == 0)
    return false;
  for (int i = 3; i * i <= x; i += 2) {
    if (x % i == 0)
      return false;
  }
  return true;
}
int main() {
  double m, a, b;
  while (cin >> m >> a >> b) {
    int ans_p, ans_q, area = 0;
    if (m == 0 && a == 0 && b == 0)
      break;
    double inf = a / b;
    for (int i = 2; i <= m; i++) {
      long tmp_area = 0, p, q;
      if (!isPrime(i))
        continue;
      for (int j = i; j <= m / i; j++) {
        // cout << i << " " << j  << endl;
        if ((double)i / j < inf || (double)i / j > 1.0)
          continue;
        if (!isPrime(j))
          continue;
        if (i * j > m)
          break;
        tmp_area = i * j;
        // cout << i << " " << j << " " << tmp_area << endl;
        p = i;
        q = j;
      }
      if (tmp_area >= area) {
        area = tmp_area;
        ans_p = p;
        ans_q = q;
      }
    }
    cout << ans_p << " " << ans_q << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 100000
using namespace std;
bool isPrime(int x) {
  if (x < 2)
    return false;
  if (x == 2)
    return true;
  if (x % 2 == 0)
    return false;
  for (int i = 3; i * i <= x; i += 2) {
    if (x % i == 0)
      return false;
  }
  return true;
}
int main() {
  double m, a, b;
  while (cin >> m >> a >> b) {
    int ans_p, ans_q, area = 0;
    if (a == 0 && b == 0 && m == 0)
      break;
    double inf = a / b;
    for (int i = 2; i <= m; i++) {
      long tmp_area = 0, p, q;
      if (!isPrime(i))
        continue;
      for (int j = i; i * j <= m / i; j++) {
        // cout << i << " " << j  << endl;
        if ((double)i / j < inf || (double)i / j > 1.0)
          continue;
        if (!isPrime(j))
          continue;
        if (i * j > m)
          break;
        tmp_area = i * j;
        // cout << i << " " << j << " " << tmp_area << endl;
        p = i;
        q = j;
      }
      if (tmp_area >= area) {
        area = tmp_area;
        ans_p = p;
        ans_q = q;
      }
    }
    cout << ans_p << " " << ans_q << endl;
  }
  return 0;
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define N 100001
using namespace std;

int main() {
  int pr[N] = {};
  pr[1] = 1;
  for (int i = 2; i * i <= N; i++)
    if (pr[i] == 0)
      for (int j = 2; j <= N / i; j++)
        pr[i * j] = 1;
  while (1) {
    int m, a, b, ansp = 0, ansq = 0, max = 0;
    cin >> m >> a >> b;
    if (m + a + b == 0)
      break;
    for (int p = 2; p <= m; p++)
      for (int q = p; q <= m / p; q++)
        if (!pr[p] && !pr[q] && p * q <= m && p * q >= max &&
            (double)p / q >= (double)a / b && (double)p / q <= 1)
          ansp = p, ansq = q, max = p * q;
    cout << ansp << " " << ansq << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define N 1000001
using namespace std;

int main() {
  int pr[N] = {};
  pr[1] = 1;
  for (int i = 2; i * i <= N; i++)
    if (pr[i] == 0)
      for (int j = 2; j <= N / i; j++)
        pr[i * j] = 1;
  while (1) {
    int m, a, b, ansp = 0, ansq = 0, max = 0;
    cin >> m >> a >> b;
    if (m + a + b == 0)
      break;
    for (int p = 2; p <= N; p++)
      for (int q = 2; q <= N; q++)
        if (!pr[p] && !pr[q] && p * q <= m && p * q >= max &&
            (double)p / q >= (double)a / b && (double)p / q <= 1)
          ansp = p, ansq = q, max = p * q;
    cout << ansp << " " << ansq << endl;
  }
  return 0;
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll

signed main() {
  int m;
  long long a, b;
  int N = 10000;
  vector<bool> p(N, true);
  vector<int> prm;
  p[0] = p[1] = false;
  for (int i = 2; i < N; i++) {
    if (p[i]) {
      for (int j = 2; j * i < N; j++)
        p[i * j] = false;
      prm.emplace_back(i);
    }
  }
  vector<int> vv = prm;
  while (scanf("%lld%lld%lld", &m, &a, &b)) {
    if (m == 0)
      break;
    int maxi = -10000000;
    int ans1, ans2;
    for (auto &&p : prm) {
      for (auto &&q : vv) {
        if (p * q > m)
          break;
        if (p * q <= m and p * b >= q * a and p * q > maxi and p <= q) {
          ans1 = max(p, q);
          ans2 = min(p, q);
          maxi = p * q;
        }
      }
    }
    printf("%d %d\\n", ans2, ans1);
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll

signed main() {
  int m;
  long double a, b;
  int N = 10000;
  vector<bool> p(N, true);
  vector<int> prm;
  p[0] = p[1] = false;
  for (int i = 2; i < N; i++) {
    if (p[i]) {
      for (int j = 2; j * i < N; j++)
        p[i * j] = false;
      prm.emplace_back(i);
    }
  }
  vector<int> vv = prm;
  sort(vv.begin(), vv.end(), greater<int>());
  while (cin >> m >> a >> b) {
    if (m == 0)
      break;
    int maxi = -10000000;
    int ans1, ans2;
    for (auto &&p : prm) {
      for (auto &&q : vv) {
        if (p / q > m || p / q > 1)
          break;
        long double p1 = (long double)p;
        long double q1 = (long double)q;
        if (p * q <= m and p1 / q1 >= a / b and p * q > maxi and p1 / q1 <= 1) {
          ans1 = max(p, q);
          ans2 = min(p, q);
          maxi = p * q;
        }
      }
    }
    cout << ans2 << " " << ans1 << endl;
  }
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;

bool f[100000] = {};

int main() {

  vector<long long int> sosu;

  for (long long int i = 2; i < 100000; i++) {

    if (f[i] == false) {
      sosu.push_back(i);
      for (long long int j = 2; j * i < 100000; j++) {
        f[j * i] = true;
      }
    }
  }

  while (true) {

    long long int m, a, b;
    cin >> m >> a >> b;
    if (m == 0)
      break;

    long long int ans_x, ans_y, cnt = 0;

    for (long long int x = 0; x < sosu.size(); x++) {
      for (long long int y = 0; y <= x; y++) {

        long long int s = sosu[x] * sosu[y];
        if (s > m)
          break;
        if (a * sosu[x] <= b * sosu[y]) {
          if (s > cnt) {
            cnt = s;
            ans_x = sosu[x];
            ans_y = sosu[y];
          }
        }
      }
    }

    cout << ans_y << " " << ans_x << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

bool f[100000] = {};

int main() {

  vector<long long int> sosu;

  for (long long int i = 2; i < 100000; i++) {

    if (f[i] == false) {
      sosu.push_back(i);
      for (long long int j = 2; j * i < 100000; j++) {
        f[j * i] = true;
      }
    }
  }

  while (true) {

    long long int m, a, b;
    cin >> m >> a >> b;
    if (m == 0)
      break;

    long long int ans_x, ans_y, cnt = 0;

    for (long long int x = 0; x < sosu.size(); x++) {
      for (long long int y = 0; y <= x; y++) {

        if (a * sosu[x] <= b * sosu[y]) {
          long long int s = sosu[x] * sosu[y];
          if (s <= m && s > cnt) {
            cnt = s;
            ans_x = sosu[x];
            ans_y = sosu[y];
          }
        }
      }
    }

    cout << ans_y << " " << ans_x << endl;
  }

  return 0;
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <vector>
using namespace std;

vector<int> p;

void Prime() {
  bool prime[100000];
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i < 100000; i++)
    prime[i] = true;
  for (int i = 2; i < 1000; i++) {
    if (!prime[i])
      continue;
    for (int j = i * 2; j < 100000; j += i)
      prime[j] = false;
  }
  for (int i = 0; i < 100000; i++)
    if (prime[i])
      p.push_back(i);
}

int main() {
  Prime();
  int m, a, b;
  while (scanf("%d%d%d", &m, &a, &b), m || a || b) {
    int aa, bb;
    int ans = 0;
    for (int i = 0; i < p.size(); i++) {
      if (p[i] > 1000)
        break;
      for (int j = i; j < p.size(); j++) {
        if (p[i] * p[j] > m || a * p[j] > b * p[i])
          break;
        if (p[i] * p[j] > ans) {
          ans = p[i] * p[j];
          aa = p[i];
          bb = p[j];
        }
      }
    }
    printf("%d %d\\n", aa, bb);
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <vector>
using namespace std;

vector<int> p;

void Prime() {
  bool prime[100000];
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i < 100000; i++)
    prime[i] = true;
  for (int i = 2; i < 1000; i++) {
    if (!prime[i])
      continue;
    for (int j = i * 2; j < 100000; j += i)
      prime[j] = false;
  }
  for (int i = 0; i < 100000; i++)
    if (prime[i])
      p.push_back(i);
}

int main() {
  Prime();
  int m, a, b;
  while (scanf("%d%d%d", &m, &a, &b), m || a || b) {
    int aa, bb;
    int ans = 0;
    for (int i = 0; i < p.size(); i++) {
      for (int j = i; j < p.size(); j++) {
        if (p[i] * p[j] > m || a * p[j] > b * p[i])
          continue;
        if (p[i] * p[j] > ans) {
          ans = p[i] * p[j];
          aa = p[i];
          bb = p[j];
        }
      }
    }
    printf("%d %d\\n", aa, bb);
  }
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<int> v;
int main() {
  for (int i = 2; i < 50000; i++) {
    bool ok = true;
    for (int j = 0; j < v.size(); j++) {
      if (i % v[j] == 0)
        ok = false;
    }
    if (ok)
      v.push_back(i);
  }
  int m, a, b;
  while (cin >> m >> a >> b && m) {
    int p = -1, q = 0;
    for (int i = 0; i < v.size(); i++) {
      for (int j = i; j < v.size(); j++) {
        if (v[i] * v[j] > m)
          break;
        if (v[j] <= b * v[i] / a) {
          if (p * q < v[i] * v[j])
            p = v[i], q = v[j];
        }
      }
    }
    cout << p << " " << q << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<int> v;
int main() {
  for (int i = 2; i < 50000; i++) {
    bool ok = true;
    for (int j = 0; j < v.size(); j++) {
      if (i % v[j] == 0)
        ok = false;
    }
    if (ok)
      v.push_back(i);
  }
  int m, a, b;
  while (cin >> m >> a >> b && m) {
    int p = -1, q = 0;
    for (int i = 0; i < v.size(); i++) {
      for (int j = i; j < v.size(); j++) {
        if (v[j] <= b * v[i] / a && v[i] * v[j] <= m) {
          if (p * q < v[i] * v[j])
            p = v[i], q = v[j];
        }
      }
    }
    cout << p << " " << q << endl;
  }
  return 0;
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<int> v;
int main() {
  for (int i = 2; i < 50000; i++) {
    bool ok = 1;
    for (int j = 0; j < v.size(); j++) {
      if (i % v[j] == 0)
        ok = 0;
    }
    if (ok)
      v.push_back(i);
  }
  int m, a, b;
  while (cin >> m >> a >> b && m) {
    int p = -1, q = 0;
    for (int i = 0; i < v.size(); i++) {
      for (int j = i; j < v.size(); j++) {
        if (v[i] * v[j] > m)
          break;
        if (v[j] <= b * v[i] / a) {
          if (p * q < v[i] * v[j])
            p = v[i], q = v[j];
        }
      }
    }
    cout << p << " " << q << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
vector<int> v;
int main() {
  int m, a, b, i, j;
  for (i = 2; i < 50000; i++) {
    bool ok = 1;
    for (j = 0; j < v.size(); j++)
      if (!i % v[j])
        ok = 0;
    if (ok)
      v.push_back(i);
  }
  while (cin >> m >> a >> b && m) {
    int p = 0, q = 0;
    for (i = 0; i < v.size(); i++) {
      for (j = i; j < v.size(); j++) {
        if (v[i] * v[j] > m)
          break;
        if (v[j] <= b * v[i] / a && p * q < v[i] * v[j])
          p = v[i], q = v[j];
      }
    }
    cout << p << " " << q << endl;
  }
  return 0;
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const int MAX = 100000;
bool prime[MAX];
vector<ll> V;
ll m, a, b;

void make() {
  fill(prime, prime + MAX, true);

  prime[0] = prime[1] = false;

  for (int i = 0; i * i < MAX; i++)
    if (prime[i])
      for (int j = 2; i * j < MAX; j++)
        prime[i * j] = false;

  for (int i = 2; i < MAX; i++)
    if (prime[i])
      V.push_back(i);
}

int main() {

  make();
  while (cin >> m >> a >> b && m + a + b) {
    P ans = P(0, 0);

    for (int i = 0; V[i] < m && i < V.size(); i++) {
      for (int j = i; V[i] * V[j] <= m && j < V.size(); j++) {
        if (a * V[j] <= b * V[i] && V[i] * V[j] > ans.first * ans.second)
          ans = P(V[i], V[j]);
      }
    }
    cout << ans.first << " " << ans.second << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, int> P;
const int MAX = 100000;
bool prime[MAX];
vector<int> V;
int m, a, b;

void make() {
  fill(prime, prime + MAX, true);

  prime[0] = prime[1] = false;

  for (int i = 0; i * i < MAX; i++)
    if (prime[i])
      for (int j = 2; i * j < MAX; j++)
        prime[i * j] = false;

  for (int i = 2; i < MAX; i++)
    if (prime[i])
      V.push_back(i);
}

int main() {
  make();
  while (cin >> m >> a >> b && m + a + b) {
    P ans = P(0, 0);

    for (int i = 0; i < V.size(); i++)
      for (int j = i; V[i] * V[j] <= m && j < V.size(); j++) {
        if (a * j <= b * i && V[i] * V[j] > ans.first * ans.second)
          ans = P(V[i], V[j]);
      }
    cout << ans.first << " " << ans.second << endl;
  }

  return 0;
}
Problem p00811 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const int N = 100000;

int main() {
  int m, a, b;
  VL d(N, 1), primes;
  FOR(x, 2, N - 1) {
    if (!d[x])
      continue;
    primes.push_back(x);
    int i = 2 * x;
    while (i < N) {
      d[i] = 0;
      i += x;
    }
  }
  while (cin >> m >> a >> b && m) {
    int ans = 0;
    int p, q;
    for (int i = 0; primes[i] <= m / 2; i++) {
      for (int j = i;
           primes[i] * primes[j] <= m && a * primes[j] <= b * primes[i]; j++) {
        if (primes[i] * primes[j] > ans) {
          ans = primes[i] * primes[j];
          p = primes[i];
          q = primes[j];
        }
      }
    }
    cout << p << " " << q << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const int N = 100000;

int main() {
  int m, a, b;
  VI d(N, 1), primes;
  FOR(x, 2, N - 1) {
    if (!d[x])
      continue;
    primes.push_back(x);
    int i = 2 * x;
    while (i < N) {
      d[i] = 0;
      i += x;
    }
  }
  while (cin >> m >> a >> b && m) {
    int ans = 0;
    int p, q;
    REP(i, primes.size()) {
      for (int j = i;
           primes[i] * primes[j] <= m && a * primes[j] <= b * primes[i]; j++) {
        if (primes[i] * primes[j] > ans) {
          ans = primes[i] * primes[j];
          p = primes[i];
          q = primes[j];
        }
      }
    }
    cout << p << " " << q << endl;
  }

  return 0;
}