| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
还有什么情况要注意阿!彻底崩溃!!!#include<stdio.h>
#include<math.h>
#define INF 0.0000000001
void main()
{
long i,j,aa,bb;double temp,rest,m,n,x;
bool flag;
while(scanf("%lf%lf",&m,&n)!=EOF)
{
flag=true;
if(m>n){
x=m;
m=n;
n=x;
flag=false;
}
if(m==0&&n!=0){printf("1 32767\n");continue;}
if(n==0&&m!=0){printf("32767 1\n");continue;}
i=1;j=1;rest=(double)m/n;temp=INF;
while(i<=32767&&j<=32767)
{
x=fabs((double)i*1.0/(double)j*1.0);
if((x-rest) < temp && (m*j!=n*i)){
temp=fabs(x-rest);
aa=i;bb=j;
}
if( x>=rest )
j++;
else
i++;
}
if(flag)
printf("%ld %ld\n",aa,bb);
else
printf("%ld %ld\n",bb,aa);
}
}
提交n次总是wrong,实在是没办法了,测试都对,求大牛指点,可发我邮箱,再次小弟拜谢!!
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator