@[lzy13915136909](/user/1021693) 说白了题给的不是x,y,而是病例与治好了的比,要你算x,y
by TLE_AK @ 2024-05-20 21:28:19
@[TLE_AK](/user/788951) @[abc1234shi](/user/941501) @[TLE_AK](/user/788951) @[__Doraemon__](/user/1283847) @[XuYueming](/user/728079) @[红黑树](/user/413140)
满江紫......
code
```cpp
#include<bits/stdc++.h>
using namespace std;
int n,a[1005],b[1005];
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i]>>b[i];
for(int i=0;i<n;i++)
{
if(b[i]/a[i]-b[1]/a[1]>0.05)
cout<<"better"<<endl;
else
{
if(a[i]/b[i]-a[1]/b[1]>0.05)
cout<<"worse"<<endl;
else
cout<<"same"<<endl;
}
}
}
return 0;
}
```
by lzy13915136909 @ 2024-05-20 21:29:57
@[lzy13915136909](/user/1021693) 先把第二个循环删了
然后把a[1],b[1]改为a[0],b[0](忘了下标0了)
还有数组int改double
你完全不测样例吗(
by TLE_AK @ 2024-05-20 21:33:18
是否应该强转double
by miffy_123 @ 2024-05-20 21:33:23
我认为你应该把第二个循环删了,a[0]b[0]单独输入,然后第一个循环改为从一到N,在循环里与第0个比较
by miffy_123 @ 2024-05-20 21:36:11
~~怎么感觉你越改越糟糕了~~
具体来说:
```cpp
int n,a[1005],b[1005];
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i]>>b[i];
```
改为
```cpp
int n,a[1005],b[1005];
cin>>n;
cin>>a[0]>>b[0];
for(int i=1;i<=n;i++)
cin>>a[i]>>b[i];
```
```cpp
if(a[i]-b[i]>0.05)
cout<<"better"<<endl;
else
{
if(b[i]-a[i]>0.05)
cout<<"worse"<<endl;
else
cout<<"same"<<endl;
}
```
改为
```
int k=(double)b[0]/a[0];
if(((double)b[i]/a[i]-k)>0.05)
cout<<"better"<<endl;
else
{
if((k-(double)b[i]/a[i])>0.05)
cout<<"worse"<<endl;
else
cout<<"same"<<endl;
}
```
by miffy_123 @ 2024-05-20 21:43:59
忘记说了,循环记得改成从1到N的
by miffy_123 @ 2024-05-20 21:44:50
@[lzy13915136909](/user/1021693)
by miffy_123 @ 2024-05-20 21:45:24
@[abc1234shi](/user/941501) @[红黑树](/user/413140) @[__Doraemon__](/user/1283847) @[XuYueming](/user/728079) @[TLE_AK](/user/788951)
AC了,我老师昨晚讲了
by lzy13915136909 @ 2024-05-22 11:57:47
@[lzy13915136909](/user/1021693) 会了就好,不要不懂装懂
by March7thDev @ 2024-05-22 19:12:43