https://uva.onlinejudge.org/external/15/1585.pdf
There is an objective test result such as OOXXOXXOOO". An `O' means a correct answer of a problem and an
OOXXOXXOOO” is 10 which is calculated by
`X' means a wrong answer. The score of each problem of this test is calculated by itself and its just previous
consecutive `O's only when the answer is correct. For example, the score of the 10th problem is 3 that is
obtained by itself and its two previous consecutive `O's.
Therefore, the score of`1+2+0+0+1+0+0+1+2+3".
O’ and
You are to write a program calculating the scores of test results.
Input
Your program is to read from standard input. The input consists of T test cases. The number of test cases T is
given in the first line of the input. Each test case starts with a line containing a string composed byX'
O’ and `X’.
and the length of the string is more than 0 and less than 80. There is no spaces between
Output
Your program is to write to standard output. Print exactly one line for each test case. The line is to contain the
score of the test case.
The following shows sample input and output for five test cases.
Sample Input
5
OOXXOXXOOO
OOXXOOXXOO
OXOXOXOXOXOXOX
OOOOOOOOOO
OOOOXOOOOXOOOOX
Sample Output
10
9
7
55
30
Seoul 2005-2006
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define INF 0x3f3f3f3f
#define eps 1e-6
#define p(x) printf("%d\n", x)
#define k(x) printf("Case %d: ", ++x)
#define mes(x, d) memset(x, d, sizeof(x))
#define s(x) scanf("%d", &x)
/*
int gcd(int a,int b)
{
return ! b ? a : gcd(b,a % b);
}
struct data
{
int val;
int pos;
int ranks;
}p[2005];
bool cmp1(const data &a,const data &b)
{
if(a.val == b.val)
return a.pos < b.pos;
return a.val < b.val;
}
bool cmp2(const data &a,const data &b)
{
return a.val > b.val;
}
bool cmp3(const data &a,const data &b)
{
return a.pos < b.pos;
}
*/
typedef long long LL;
const double pi = acos(-1.0);
const long long mod = 1e9 + 7;
using namespace std;
char s[105];
int main()
{
//freopen("int.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T;
scanf("%d",&T);
while(T--)
{
scanf("%s",s);
int ans = 0;
int len = strlen(s);
int t = 0;
for(int i = 0;i < len;i++)
{
if(s[i] == 'O')
t++;
else
t = 0;
ans += t;
}
printf("%d\n",ans);
}
return 0;
}