1 条题解
-
2
#include<iostream> #include<algorithm> #include<cmath> #include<cstdio> #include<cstring> #include<string> using namespace std; int a,b,c; int fun1(int fun1a,int fun1b){ if(fun1a%fun1b==0) return fun1b; else return fun1(fun1b,fun1a%fun1b); } int main(){ scanf("%d %d %d",&a,&b,&c); double ab1 = a*1.0/b; double tmp; double ab2=101; int res1=0,res2=0; for(int i=1;i<=c;i++){ for(int j=1;j<=c;j++){ if(fun1(i,j)!=1){ continue; } if(b*i<a*j){ continue; } tmp = i*1.0/j; if(tmp-ab1<ab2){ ab2 = tmp-ab1; res1 = i; res2 = j; } } } printf("%d %d",res1,res2); return 0; }
- 1
信息
- ID
- 1076
- 时间
- 1000ms
- 内存
- 125MiB
- 难度
- 2
- 标签
- 递交数
- 15
- 已通过
- 12
- 上传者