Why D
  • 板块学术版
  • 楼主Guoguo2013
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/12/14 22:07
  • 上次更新2024/12/15 09:30:13
查看原帖
Why D
1070982
Guoguo2013楼主2024/12/14 22:07
#include<bits/stdc++.h>
#define int long long
#define PII pair< int, int >

using namespace std;

const int N = 2e5 + 5, mod = 998244353;
int n, s, a[N];

template< typename T >inline void read(T &x){bool f=1;x=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-') f=!f;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}x=(f?x:-x);return;}
template< typename T, typename ... L > void read(T &a , L && ... b) { read(a); read(b ...); }
int ksm(int a, int b, int p){int ans = 1;while(b){if(b & 1)ans =(ans*a)%p;b >>= 1;a = (a*a) % p;}return ans;}
signed main(){
//	freopen("a.in", "r", stdin);
//	freopen("a.out","w",stdout);
	read(n, s);
	for (int i = 1; i <= n; i++){
		read(a[i]);
		a[i] += a[i-1];
	}
	s %= a[n];
	for (int i = 0, j = 0; j <= n; ){
		if (a[j] - a[i] == s){
			printf("Yes");
			return 0;
		}
		if (a[j] - a[i] < s) j++;
		else i++;
	}
	printf("No");
	return 0;
}

赛时调半小时没调出来,去做 E 了,结果赛后 2121 分钟做出来了。

2024/12/14 22:07
加载中...