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. 三分钟在任何电脑上使用 chrome os

    准备 什么是 chrome os? Chrome OS是一款Google开发的基于PC的操作系统. Google Chrome OS是一款基于Linux的开源操作系统. Chrome OS 系统和 C ...

  2. Springboot 2.X的RequestMapping 的映射路径怎么看不到了?

    在使用spring boot 1.X的时候我们可以在console中看到mapping的映射路径 2020-01-12 19:10:19.996 INFO 2711 --- [ main] s.w.s ...

  3. linux之文件基本操作

    文件/目录管理命令: cd命令主要是改变目录的功能 cd ~ 返回登录目录 cd / 返回系统根目录 cd ../ 或者cd ..  返回上一级目录 cd -  返回上一次访问的目录 pwd命令用于显 ...

  4. Electron 初识-搭建一个简易桌面应用

    Electron ​ 快速入门 简介 Electron 可以让你使用纯 JavaScript 调用丰富的原生 APIs 来创造桌面应用.你可以把它看作是专注于桌面应用而不是 web 服务器的,io.j ...

  5. mssql 手工注入流程小结

    对于MSSQL的注入点,无外乎这三种权限:SA,DB_OENER,PUBLIC.SA(System Admin)权限我们可以直接执行命令,DB_OENER权限的话,我们可以找到WEB的路径,然后用备份 ...

  6. 一行一行源码分析清楚AbstractQueuedSynchronizer

    ​“365篇原创计划”第二十四篇. 今天呢!灯塔君跟大家讲: 一行一行源码分析清楚AbstractQueuedSynchronizer 在分析 Java 并发包 java.util.concurren ...

  7. 附007.Docker全系列大总结

    Docker全系列总结如下,后期不定期更新. 欢迎基于学习.交流目的的转载和分享,禁止任何商业盗用,同时希望能带上原文出处,尊重ITer的成果,也是尊重知识. 若发现任何错误或纰漏,留言反馈或右侧添加 ...

  8. SQLAlchemy04 /SQLAlchemy查询高级

    SQLAlchemy04 /SQLAlchemy查询高级 目录 SQLAlchemy04 /SQLAlchemy查询高级 1.排序 2.limit.offset和切片操作 3.懒加载 4.group_ ...

  9. 数据可视化之PowerQuery篇(四)二维表转一维表,看这篇文章就够了

    https://zhuanlan.zhihu.com/p/69187094 数据分析的源数据应该是规范的,而规范的其中一个标准就是数据源应该是一维表,它会让之后的数据分析工作变得简单高效. 在之前的文 ...

  10. Java并发编程实践

    最近阅读了<Java并发编程实践>这本书,总结了一下几个相关的知识点. 线程安全 当多个线程访问某个类时,不管运行时环境采用何种调度方式或者这些线程将如何交替执行,并且在主调代码中不需要任 ...