#39445: line:12 WA


s111110507@student.nqu.edu.tw (yc.)

學校 : 國立金門大學
編號 : 217509
來源 : [1.172.154.172]
最後登入時間 :
2024-03-11 22:46:41
d123. 11063 - B2-Sequence -- UVa11063 | From: [118.163.250.12] | 發表日期 : 2024-02-22 11:37

附上程式碼
 
#include<bits/stdc++.h>
using namespace std;

 

int main()
{
    int n,t=0;
    bool c;
    while(cin>>n)
    {
        t++;
        int x[n];
        c=true;
        for(int a=0;a<n;a++)
        {
            cin>>x[a];
            if(x[a]<1)
            {
                c=false;
                break;
            }
            if(a>0&&x[a]>x[a-1])
            {
                c=false;
                break;
            }
        }
        if(c)
        {
            map<int,int>y;
            for(int a=0;a<n;a++)
            {
                for(int b=0;b<=a;b++)
                {
                    y[x[a]+x[b]]++;
                }
            }
            for(auto &z:y)
            {
                if(z.second>1)
                {
                    c=false;
                    break;
                }
            }
        }
        if(c)
        {
            cout<<"Case #"<<t<<": It is a B2-Sequence."<<endl<<endl;
        }
        else
        {
            cout<<"Case #"<<t<<": It is not a B2-Sequence."<<endl<<endl;
        }
    }
}
 
#39523: Re: line:12 WA


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
d123. 11063 - B2-Sequence -- UVa11063 | From: [101.136.169.178] | 發表日期 : 2024-03-02 21:31

            if(a>0&&x[a]>x[a-1])
            {
                c=false;
                break;
            }


刪掉

 
ZeroJudge Forum