You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB

2 years ago
#include <bits/stdc++.h>
using namespace std;
/*
L 100 A,B
(1)A,B
(2)AB AB
(A',B'),gcd(A',B')>1(A'/d,B'/d).
x-X<mi,(A',B')$A'/d,B'/d$
,logLO(L^2 LogL) O(L^2)
*/
int main() {
int A, B, L;
cin >> A >> B >> L;
int a, b;
double mi = 1e9;
for (int i = 1; i <= L; i++)
for (int j = 1; j <= L; j++) {
double x = i * 1.0 / j;
double X = A * 1.0 / B;
if (x >= X && x - X < mi) {
mi = x - X;
a = i, b = j;
}
}
cout << a << ' ' << b << endl;
return 0;
}