求调78pts
查看原帖
求调78pts
882193
Blue_Flower楼主2023/10/6 20:01
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans=0;

inline int read()
{
	char c=getchar();
	int x=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x; 
}

int main()
{
	n=read();
	int tmp,pos=0;
	for(int i=1;i<=n;i++)
	{
		tmp=read();
		if(tmp==5)
		{
			pos++;
			ans+=(pos*(pos+1))/2;
			ans%=1000000007;
			ans+=pos*(i-pos);
			ans%=1000000007;
		}
		else pos=0;
	}
	cout<<ans;
}

Subtask #2 WA

2023/10/6 20:01
加载中...