水题----根据O出现次数判断分数
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出现次数判断分数的更多相关文章
- 水题 Codeforces Beta Round #70 (Div. 2) A. Haiku
题目传送门 /* 水题:三个字符串判断每个是否有相应的元音字母,YES/NO 下午网速巨慢:( */ #include <cstdio> #include <cstring> ...
- cdoj 26 遮挡判断(shadow) 水题
遮挡判断(shadow) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 ...
- HDU 2108 逆时针给出多边形的顶点,判断是否为凸多边形,水题
下面是别人解题报告的链接,很详细,写的很好 http://blog.csdn.net/chl_3205/article/details/8520597 下面贴我的代码 #include <cst ...
- hrbustoj 1306:再遇攻击(计算几何,判断点是否在多边形内,水题)
再遇攻击 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 253(37 users) Total Accepted: 56(2 ...
- CodeForces 690C1 Brain Network (easy) (水题,判断树)
题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...
- 蓝桥杯 第四届C/C++预赛真题(5) 前缀判断(水题)
题目标题:前缀判断 如下的代码判断 needle_start指向的串是否为haystack_start指向的串的前缀,如不是,则返回NULL. 比如:"abcd1234" 就包含了 ...
- hdu3793 判断对称(水题)
题意: 给你一个串,问你这个串是不是关于某个字母对称的,这个串是一个首位相接的圆. 思路: 水题,直接枚举每一个为对称点试一下就行了,不解释了. #include<std ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
- UVa 1339 Ancient Cipher --- 水题
UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...
随机推荐
- JavaScript this 关键词
this是什么呢? JavaScript this 关键词指的是它所属的对象. 它拥有不同的值,具体取决于它所使用的位置: 在方法中,this 指的是所有者对象. 单独的情况下,this 指的是全局对 ...
- vue全家桶(3.2)
4.5.创建实例 可以创建一个自定义实例应用于多个请求接口 <template> <div class="page"> </div> </ ...
- Python进阶之浅谈内置方法
目录 有序or无序和可变or不可变 数字类型内置方法 整形 浮点型 字符串类型内置方法 有序or无序和可变or不可变 有序:有索引 无序:无索引 可变:变量值变,id不变 不可变:变量值变,id也变 ...
- C++ 简单的UDP客户端与服务端
.h #pragma once #ifndef __C_UDP_OBJECT_H__ #define __C_UDP_OBJECT_H__ #define OS_PLATFORM_WIN #inclu ...
- C++ 自动资源释放的单例模式
代码思想就是程序结束时会自动释放静态/全局资源时删除单例资源. //.h class CSingleton { public: static CSingleton* Singleton() { ret ...
- SpringMVC的项目架构思想
SpringMVC的项目架构思想 一.DO和Model的区别 DO是对数据库表的映射.Model是处理业务逻辑的模型(领域模型).例如:用户信息表和用户密码表分别是两个DO,但是对于实体用户来说,密码 ...
- (私人收藏)2019WER积木教育机器人赛(普及赛)解决方案-(全套)获取能源核心
2019WER积木教育机器人赛(普及赛)解决方案-(全套)获取能源核心 含地图,解决程序,详细规则,搭建方案EV3;乐高;机器人比赛;能力风暴;WER https://pan.baidu.com/s/ ...
- web前端工程化/构建自动化
前端工程化 前端工程化的概念在近些年来逐渐成为主流构建大型web应用不可或缺的一部分,在此我通过以下这三方面总结一下自己的理解. 为什么需要前端工程化. 前端工程化的演化. 怎么实现前端工程化. 为什 ...
- [POI2014]FAR-FarmCraft (树规+贪心)
题干 In a village called Byteville, there are houses connected with N-1 roads. For each pair of houses ...
- 读CSAPP第二章的收获
一:一道很有意思的位运算题目:你只有两种操作 bis(x, y): 在y为1的每个位置上,将x的对应的位设为1bic(x, y): 在y为1的每个位置上,将x的对应的位设为0 简单的化简一下bis(x ...