Files
python/TangDou/XiTi/1131.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

25 lines
645 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}