mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-30 18:36:27 +00:00
P2118 比例简化
R40130533
This commit is contained in:
parent
51a98ba4b7
commit
fe44b6f366
26
problem/P2118/P2118.cpp
Normal file
26
problem/P2118/P2118.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int gcd(int x, int y) {
|
||||
if (!y) {
|
||||
return x;
|
||||
}
|
||||
return gcd(y, x % y);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int a, b, l;
|
||||
cin >> a >> b >> l;
|
||||
int ansa = l, ansb = 1;
|
||||
for (int i = 1; i <= l; i++) {
|
||||
for (int j = 1; j <= l; j++) {
|
||||
if (gcd(i, j) == 1 && i * b >= j * a && i * ansb < j * ansa) {
|
||||
ansa = i;
|
||||
ansb = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << ansa << ' ' << ansb << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user