WHY D?
  • 板块学术版
  • 楼主luogu_hezhenmin1
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/12/14 21:52
  • 上次更新2024/12/15 09:18:12
查看原帖
WHY D?
1329138
luogu_hezhenmin1楼主2024/12/14 21:52
#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
const int N=4e5+2;
int n,a[N],s,c[N];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>s;
    for (int i = 1; i <= n; i++)
    {
        cin>>a[i];
        if(a[i]==s){
            cout<<"YES"<<'\n';
            system("pause");
            return 0;
        }
        c[i]=c[i-1]+a[i];
    }
    //cout<<c[n]<<"\n";
    int kn=s%c[n];
    for (int i = 1; i <=n; i++)
    {
        a[i+n]=a[i];
        c[i+n]=c[n]+c[i];
    }
    for (int i = 1; i <= n*2; i++)
    {
        int l=i+1,r=n*2;
        while (l<r)
        {
            int mid=(l+r)>>1;
            if((c[mid]-c[i])==kn){
                cout<<"YES"<<'\n';
                system("pause");
                return 0;
            }
            else if((c[mid]-c[i])<kn) l=mid+1;
            else r=mid-1;
        }
        if((c[l]-c[i])==kn){
            cout<<"YES"<<'\n';
            system("pause");
            return 0;
        }
    }
    cout<<"NO"<<'\n';
    system("pause");
    return 0;
}

my code为啥是WA 0pts

2024/12/14 21:52
加载中...