0
已采纳
王逸凡
初级守护
初级守护
#include<iostream>
using namespace std;
double a,b,l;
double a1,b1,minn;
bool hz(int x,int y){
int r;
while(x%y!=0){
r=x%y;
x=y;
y=r;
}
if(y==1){
return 1;
}
else{
return 0;
}
}
int main()
{
cin>>a>>b>>l;
double t=a/b,minn=1000;
for(int i=1;i<=l;i++){
for(int j=1;j<=l;j++){
double k=i*1.0/j;
if(hz(i,j)&&k>=t){
if(k-t<minn){
minn=k-t;
a1=i;
b1=j;
}
}
}
}
cout<<a1<<" "<<b1;
return 0;
}