Files
python/TangDou/XiTi/1131.cpp

25 lines
645 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#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;
}