Score
UVA - 1585
题目传送门
题目大意:输入一个字符串,O的分数为1,若出现连续的O,如OOOO...,分数为1,2,3,4...,X为0分,求最终的分数
AC代码:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
int main()
{//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);int t;cin>>t;while(t--){string s;cin>>s;int ans=0,m=1;for(int i=0;i<s.size();i++){if(s[i]=='O'){ans+=m;m++; //出现连续的O,分数累加}elsem=1; //遇到X,分数复位}cout<<ans<<endl;}return 0;
}