codeforces 1084 C. The Fair Nut and String

题目来源

思路: 

 

我们考虑在字符串末尾增加一个”哨兵“,其值为b。然后用b对a进行分割,每一段a 的个数为ai。

最后统计结果:(a1+1)*(a2+1)*...*(ax+1)-1。这里减去1是因为至少没有什么都不选的情况。

代码:

#include
const int mod=1e9+7;
using namespace std;

int main(){
	char s[100005];
	memset(s,'\0',sizeof(s));
	while(~scanf("%s",s)){
		s[strlen(s)]='b';
		int a[100005];
		int d=0;
		int mark=0;
		for(int i=0;i

 

你可能感兴趣的:(codeforces 1084 C. The Fair Nut and String)