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.

25 lines
645 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
float a, b, l;
float ans = INT32_MAX, bns = 1;
int main() {
cin >> a >> b >> l;
for (float i = 1; i <= l; i++) {
for (float j = 1; j <= l; j++) {
//注意这个__gcd只能处理整数不能处理浮点需要强制转换一下。
if (__gcd(int(i), int(j))) {
if (i / j >= a / b) {
if (i / j < ans / bns) {
ans = i;
bns = j;
}
}
}
}
}
cout << ans << " " << bns;
return 0;
}