显示代码纯文本
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int A,B,L;
int gcd(int a,int b)
{return !b?a:gcd(b,a%b);}
int Ans1,Ans2;
double temp=0x7ffffff;
int main()
{
freopen("ratio.in","r",stdin);
freopen("ratio.out","w",stdout);
scanf("%d%d%d",&A,&B,&L);
for(int i=1;i<=L;i++)
{
for(int j=1;j<=L;j++)
{
if(gcd(i,j)==1&&((double)(A*1.0)/B<=(double)(i*1.0)/j))
{
if((i*1.0)/j-(A*1.0)/B<temp)
{
temp=(i*1.0)/j-(double)(A*1.0)/B;
Ans1=i,Ans2=j;
}
}
}
}
printf("%d %d",Ans1,Ans2);
fclose(stdin);
fclose(stdout);
return 0;
}