1324. Score
来源:互联网 发布:柏柏尔人 知乎 编辑:程序博客网 时间:2024/05/21 19:29
1324. Score
Description
There is an objective test result such as ``OOXXOXXOOO". An `O' means a correct answer of a problem and an `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 ``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.
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 by `O' and `X' and the length of the string is more than 0 and less than 80. There is no spaces between `O' and `X'.
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
// source code of submission 966412, Zhongshan University Online Judge System#include <iostream>#include <string>#include <cstring>using namespace std;int main(){ int n,len,sum,count = 1; cin >> n; string str; for (int i = 1; i <= n ; i++) { cin >> str; len = str.length(); sum = 0; for(int k = 0; k < len ; k++ ) { if (str[k] == 'O') { sum += count; if( k < len - 1 && str[k+1] == 'O') { count ++; } else count = 1; } } cout << sum << endl; } return 0;}
- 1324. Score
- sicily--1324. Score
- ACM 1324. Score
- sicily 1324.Score
- soj 1324. Score
- Sicily 1324. Score
- [sicily]1324. Score
- Score
- score
- score
- Score
- Score
- Score
- Score
- 1324. Score 继续水题
- Inception Score&Mode Score
- high score
- score someone
- CodeSite使用小结
- PLSQL Developer 连接数据库 弹出空白对话框 解决方法
- FSharp 3.0 开发者预览版
- mako模板笔记
- QT6410移植linux-2.6.39 笔记(三)-构建cramfs根文件系统(1)
- 1324. Score
- 关于jquery 的跨域访问问题 (spring mvc +jquery) (怕别人搜索不到加上点关键字哈 springmvc ajax 跨域 jquery jsp javascript js)
- SONET/SDH概述
- 批处理经验积累
- 第一个UML图
- connect 和accept区别
- 1306. Sorting Algorithm
- JBPM流程通过Aciton动态创建TaskInstance来实现“会签”
- wpf 选择文件夹及文件选择