竞赛讨论区 > J题用double做只对一半改为longlongint就全对
头像
qing~~
编辑于 2019-07-18 21:46
+ 关注

J题用double做只对一半改为longlongint就全对

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
 double x,a,y,b;
 while(cin>>x>>a>>y>>b)
 {
  double xa=floor(x/a);
  double yb=floor(y/b);
  if(xa>yb){
   cout<<">\n";
  }
  else if(xa<yb){
   cout<<"<\n";
  }
  else 
  {
   double aa=fmod(x,a)*b,bb=fmod(y,b)*a;
   if(aa>bb) cout<<">\n";
   else if(aa==bb) cout<<"=\n";
   else cout<<"<\n";
  }
   
 } 
 return 0;
}
double都改为long long int就都对了,为什么?

全部评论

(1) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐