Kevinyyds @ 2022-08-15 08:43:07
#include<bits/stdc++.h>
using namespace std;
int n,a,b,x,y;
double c,z;
int main()
{
cin>>n;
cin>>x>>y;
z=x*1.00/y;
for(int i=2;i<=n;i++)
{
cin>>a>>b;
c=a*1.00/b;
if(z-c>0.05)
cout<<"better"<<endl;
else
if(c-z>0.05)
cout<<"worse"<<endl;
else
cout<<"same"<<endl;
}
return 0;
}
这哪里错了? WA两个 https://www.luogu.com.cn/record/83821102
by Eydte @ 2022-08-15 09:12:56
@Kevinyyds 改成 1.00*a/b
试试
by Eydte @ 2022-08-15 09:28:07
或者全部用double
,直接除,比较
by Kevinyyds @ 2022-08-15 11:01:21
https://www.luogu.com.cn/record/83840509
#include<bits/stdc++.h>
using namespace std;
double n,a,b,x,y,c,z;
int main()
{
cin>>n;
cin>>x>>y;
z=1.00*x/y;
for(int i=2;i<=n;i++)
{
cin>>a>>b;
c=1.00*a/b;
if(z-c>0.05)
cout<<"better"<<endl;
else
if(c-z>0.05)
cout<<"worse"<<endl;
else
cout<<"same"<<endl;
}
return 0;
}
还是老样子
by kuikuidadi @ 2023-01-23 15:37:14
https://www.luogu.com.cn/record/100412654#:~:text=15%3A33%3A53-,%E6%B5%8B%E8%AF%95%E7%82%B9%E4%BF%A1%E6%81%AF,Accepted%2C%20%E5%BE%97%E5%88%86%2010.ok%20accepted,-%E5%9C%A8%E6%B4%9B%E8%B0%B7 你这样改就可以了!!!
#include<bits/stdc++.h>
using namespace std;
double n,a,b,x,y,c,z;
int main()
{
cin>>n;
cin>>x>>y;
z=y/x;
for(int i=2;i<=n;i++)
{
cin>>a>>b;
c=b/a;
if(c-z>0.05)
cout<<"better"<<endl;
else
if(z-c>0.05)
cout<<"worse"<<endl;
else
cout<<"same"<<endl;
}
return 0;
}