满江红QAQ

B2065 鸡尾酒疗法

lzy13915136909 @ 2024-05-20 21:06:00

本蒟蒻的code......

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[1005],b[1005];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    for(int i=0;i<n;i++)
    {
        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;
        }
    }
    return 0;
}

来自一个六年级蒟蒻的彷徨


by TLE_AK @ 2024-05-20 21:28:19

@lzy13915136909 说白了题给的不是x,y,而是病例与治好了的比,要你算x,y


by lzy13915136909 @ 2024-05-20 21:29:57

@TLE_AK @abc1234shi @TLE_AK @Doraemon @XuYueming @红黑树 满江紫...... code

#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 TLE_AK @ 2024-05-20 21:33:18

@lzy13915136909 先把第二个循环删了 然后把a[1],b[1]改为a[0],b[0](忘了下标0了) 还有数组int改double 你完全不测样例吗(


by miffy_123 @ 2024-05-20 21:33:23

是否应该强转double


by miffy_123 @ 2024-05-20 21:36:11

我认为你应该把第二个循环删了,a[0]b[0]单独输入,然后第一个循环改为从一到N,在循环里与第0个比较


by miffy_123 @ 2024-05-20 21:43:59

怎么感觉你越改越糟糕了 具体来说:


    int n,a[1005],b[1005];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];

改为


    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];
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:44:50

忘记说了,循环记得改成从1到N的


by miffy_123 @ 2024-05-20 21:45:24

@lzy13915136909


by lzy13915136909 @ 2024-05-22 11:57:47

@abc1234shi @红黑树 @Doraemon @XuYueming @TLE_AK AC了,我老师昨晚讲了


by March7thDev @ 2024-05-22 19:12:43

@lzy13915136909 会了就好,不要不懂装懂


上一页 | 下一页