There is an objective test result such as \OOXXOXXOOO". An `O' means a correct answer of a problemand an `X' means a wrong answer. The score of each problem of this test is calculated by itself andits just previous consecutive `O's only when the answer is correct. For example, the score of the 10thproblem is 3 that is obtained by itself and its two previous consecutive `O's.Therefore, the score of \OOXXOXXOOO" is 10 which is calculated by \1+2+0+0+1+0+0+1+2+3".You are to write a program calculating the scores of test results.InputYour program is to read from standard input. The input consists ofTtest cases. The number of testcasesTis given in the rst line of the input. Each test case starts with a line containing a stringcomposed by `O' and `X' and the length of the string is more than 0 and less than 80. There is no spacesbetween `O' and `X'.OutputYour program is to write to standard output. Print exactly one line for each test case. The line is tocontain the score of the test case.

Sample Input

5

OOXXOXXOOO

OOXXOOXXOO

OXOXOXOXOXOXOX

OOOOOOOOOO

OOOOXOOOOXOOOOX

Sample Output

10

9

7

5

5

30

解析:根据次数判加几

ac代码

#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    int n;
    cin>>n;
    getchar();
    while(n--)
    {
        getline(cin,s);
        int ans=0,flag=0;
        for(int i=0; i<s.length(); i++)
        {
            if(s[i]=='O')
            {
                flag++;
                ans+=flag;
            }
            else
                flag=0;
        }
        cout<<ans<<endl;
    }
    return 0;
}

水题----根据O出现次数判断分数的更多相关文章

  1. 水题 Codeforces Beta Round #70 (Div. 2) A. Haiku

    题目传送门 /* 水题:三个字符串判断每个是否有相应的元音字母,YES/NO 下午网速巨慢:( */ #include <cstdio> #include <cstring> ...

  2. cdoj 26 遮挡判断(shadow) 水题

    遮挡判断(shadow) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 ...

  3. HDU 2108 逆时针给出多边形的顶点,判断是否为凸多边形,水题

    下面是别人解题报告的链接,很详细,写的很好 http://blog.csdn.net/chl_3205/article/details/8520597 下面贴我的代码 #include <cst ...

  4. hrbustoj 1306:再遇攻击(计算几何,判断点是否在多边形内,水题)

    再遇攻击 Time Limit: 1000 MS    Memory Limit: 65536 K Total Submit: 253(37 users)   Total Accepted: 56(2 ...

  5. CodeForces 690C1 Brain Network (easy) (水题,判断树)

    题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...

  6. 蓝桥杯 第四届C/C++预赛真题(5) 前缀判断(水题)

    题目标题:前缀判断 如下的代码判断 needle_start指向的串是否为haystack_start指向的串的前缀,如不是,则返回NULL. 比如:"abcd1234" 就包含了 ...

  7. hdu3793 判断对称(水题)

    题意:       给你一个串,问你这个串是不是关于某个字母对称的,这个串是一个首位相接的圆. 思路:       水题,直接枚举每一个为对称点试一下就行了,不解释了. #include<std ...

  8. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

  9. UVa 1339 Ancient Cipher --- 水题

    UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...

随机推荐

  1. java8 Optional 类

    package jdk180reduce; import java.util.ArrayList; import java.util.HashMap; import java.util.List; i ...

  2. Github仓库如何选择开源许可证

    Github仓库如何选择开源许可证 目录 Github仓库如何选择开源许可证 为什么需要开源许可证? 不使用开源许可证对于开发者有何影响? 不使用开源许可证对于项目的使用者有何影响? Github的开 ...

  3. 面试官:你精通多少种语言的 Hello World?

    Hello World,是程序员入门编程语言的第一课.不论是C.C++还是Java ,我们写的第一个程序就是它了,还记得小编在大一C语言课上,花了一整节课时间才把它打印到控制台上.万事开头难啊,相信看 ...

  4. python冷知识(续)

    python 冷知识 1.交互式中修改最大递归深度 大家都知道使用递归是有风险的,递归深度过深容易导致堆栈的溢出. 那到底,默认递归次数限制是多少呢? 可以使用sys这个库来查看 >>&g ...

  5. Taro 3 正式版发布:开放式跨端跨框架解决方案

    作者:凹凸曼 - yuche 从 Taro 第一个版本发布到现在,Taro 已经接受了来自于开源社区两年多的考验.今天我们很高兴地在党的生日发布 Taro 3(Taro Next)正式版,希望 Tar ...

  6. 关于Spring Boot中的业务层(Service)是否要创建接口的分析

    在借助Spring Boot框架开发web项目时,在业务层(Service)这一部分,标准做法是:定义一个接口,然后再一个或多个类去实现.那么疑问来了: 为什么我们要维护两份同构代码,而不直接使用一个 ...

  7. node实现文件属性批量修改(文件名)

    前言 书接上回,我们实现了批量修改文件的时间,但是却没有实现文件名称的批量修改,是因为我也说过,没有界面的话直接在命令行实现显得有点繁琐,所以我们就通过接口+界面的方式来实现我们这个小需求吧.所以,闲 ...

  8. 【线型DP】CF1012C Hills 小山坡

    来了来了. 题目: 给你n个数,你一次操作可以把某一个数-1(可以减为负数),你的目标是使任意的k个数严格小于它旁边的两个数(第一个数只用严格小于第二个数,第n个数只用严格小于第n-1个数),问最少需 ...

  9. Bank Hacking题解

    题目: 题意: 有一颗树,你可以断开点(第一个随便断,以后只能是和已经断开的点相临的点),每个点有权值,断开之后,经一条边和两条边可以到达的节点权值加一,问到最后出现过的最大的权值. 分析: 为啥断开 ...

  10. cf1216E2 Numerical Sequence (hard version) 二分查找、思维题

    题目描述 The only difference between the easy and the hard versions is the maximum value of k. You are g ...