题解:循环统计连续的O将对应的分数加上即可。
AC代码:
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 87;
#define _for(i,a,b) for(int i=a;i<=b;i++)
char s[maxn];
int ans,n;
int main()
{
scanf("%d",&n);
while(n--)
{
scanf("%s",s);
int leng = strlen(s);
int last = 1;
int sum = 0;
_for(i,0,leng-1)
{
if(s[i]=='O')
{
sum+=last;
last++;
}
else last = 1;
}
printf("%d\n",sum);
}
return 0;
}