欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Score, ACM/ICPC Seoul 2005, UVa1585

程序员文章站 2022-03-13 19:28:53
...

Score, ACM/ICPC Seoul 2005, UVa1585

#include <iostream>
#include <string>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t-- > 0)
	{
		string s;
		cin >> s;
		int sum = 0, consecutive = 0;
		int len = s.length();
		for (int i = 0; i < len; ++i)
		{
			if (s[i] == 'X')
			{
				consecutive = 0;
			}
			else if (s[i] == 'O')
			{
				++consecutive;
				sum += consecutive;
			}
		}
		cout << sum << endl;
	}
}