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.
Sample Input
5
OOXXOXXOOO
OOXXOOXXOO
OXOXOXOXOXOXOX
OOOOOOOOOO
OOOOXOOOOXOOOOX
Sample Output
10
9
7
55
30

问题链接:UVA1585 LA3354 Score
问题简述:(略)
问题分析
    这个题是计算得分,得分规则有点像保龄球以及跳一跳的得分规则,连续正确的次数越多分数越高。
    这个题逻辑简单,用3种语言实现。
程序说明:解题代码在LA3354(UVALive3354)中会出现WA,不理解。
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA1585 LA3354 Score */#include <bits/stdc++.h>using namespace std;int main()
{ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);int t;cin >> t;while(t--) {string s;cin >> s;int ans = 0, cnt = 0;for(int i = 0; s[i]; i++)if(s[i] == 'O') ans += ++cnt;else cnt = 0;cout << ans << endl;}return 0;
}

AC的C语言程序(字符流)如下:

/* UVA1585 LA3354 Score */#include <stdio.h>int main(void)
{int t;scanf("%d", &t);getchar();while(t--) {int ans = 0, cnt = 0;char c;while((c = getchar()) != '\n') {if(c == 'O') ans += ++cnt;else if(c == 'X') cnt = 0;}printf("%d\n", ans);}return 0;
}

AC的C语言程序(格式化输入)如下:

/* UVA1585 LA3354 Score */#include <stdio.h>#define N 80
char s[N + 1];int main(void)
{int t, i;scanf("%d", &t);while(t--) {int ans = 0, cnt = 0;scanf("%s", s);for(i = 0; s[i]; i++)if(s[i] == 'O') ans += ++cnt;else cnt = 0;printf("%d\n", ans);}return 0;
}

AC的Python语言程序如下:

# UVA1585 LA3354 Scoret = int(input())
for k in range(t):a = input()ans = 0cnt = 0for i in a:if i == 'O':cnt += 1ans += cntelse:cnt = 0print(ans)

UVA1585 LA3354 Score【水题】相关推荐

  1. UVA1585 UVALive3354 Score【水题】

      There is an objective test result such as "OOXXOXXOOO". An 'O' means a correct answer of ...

  2. hdu-5003 Osu!(水题)

    题目链接: Osu! time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Prob ...

  3. zcmu之水题来一波~

    1036: Shepherd 1112: 对于数字的强迫症 1137: 最后一次队内赛的a+b 1278: Sequence(哈希) 1279: Sort photos(读题) 1653: 这样真的好 ...

  4. zcmu-1653,1654...【水题集合】

    1653: 这样真的好么(*^*) Description 在某人参加的某一场比赛中,一共有k位选手参赛,他们的编号是1到k.主办方准备了n个气球,主办方同样把这n个气球随机的编号为1到k中的一个数( ...

  5. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  6. HDU2673-shǎ崽(水题)

    如果不能够直接秒杀的题,就不算水题.又应证了那句话,有时候,如果在水题上卡住,那么此题对于你来说,也就不算是水题了额~~ 刚睡醒,迷迷糊糊. 题目的意思很简单,求一个最大的,再求一个最小的.几乎是什么 ...

  7. 图论刷水题记录(二)(最短路-----SPFA算法)

    继第一篇的后续,又来刷水题了,写的是SPFA算法,这个算法的复杂度比较玄学,感觉能不用就不用了,但是他的好处就是可以判断负圈. 3月26日: 1.POJ 1847 Tram 题意:在一个交通网络上有N ...

  8. 图论刷水题记录(一)(最短路-----dijkstra算法)

    最近实在不知道干些什么,感觉自己除了水题什么都不会做,算了去刷一刷图论的水题吧本来想合起来一起发,想了想太长的话以后看起来也不方便,题目所以今天晚上就先发了dij部分,由上到下由易变难. 1.POJ ...

  9. hdu 2041:超级楼梯(水题,递归)

    超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

最新文章

  1. AI拟音师出击,轻松骗过人类观众:你听到的电影音效可能来自它们
  2. pvrect r语言 聚类_R语言一条命令实现基于样本和距离的聚类分析
  3. 《深入理解java虚拟机》
  4. 小波变换工程实现原理总结
  5. oracle字体加粗函数_Oracle日期操作函数
  6. Leetcode每日一题:83.remove-duplicates-from-sorted-list(删除排序链表中的重复元素)
  7. cut out数据增强_被多种离散化场景困扰?8种python技巧!让数据处理更简单
  8. react router 4
  9. 计算机组成原理保姆级复习资料
  10. 用纯CSS3的animation制作雪花飘落、星星闪烁、按钮缩放、图片倾斜
  11. 我的世界服务器宝石系统指令,《我的世界》作弊码大全 MC当中所有的指令总汇...
  12. 微信小程序开发学习—Day1
  13. 【网络驱动】GMAC 系统框架
  14. c语言1到20联程,闫超
  15. CentOS7 或 Ubuntu20.04、22.04 安装最新版 Podman-4.1.1,离线安装请移步到连接
  16. ROS基础---ros通信、ros发布者publisher、publisher.cpp、Talker.cpp
  17. GP2Y10粉尘传感器
  18. python执行定时任务
  19. 珠海:IT应用向政府投资行业集中
  20. 浙江大学计算机博士申请考核,考博经验 | 2020年浙江大学博士申请考核经验分享...

热门文章

  1. openssl 1.1.1b 如何制作SM2公钥(在Ubuntu 19.04下测试通过)
  2. Arcgis server——arcgis server manager忘记密码
  3. Unity调用动态链接库dll和so
  4. 个性化Unity游戏开发环境两则
  5. GitHub上最火的40个iOS开源项目(二)
  6. Cocos2d-x学习之创建Android工程和编译
  7. Memcached windows 下安装与应用
  8. 一种软阴影的实现方法
  9. html5做在线音乐,html5实现在线响应式音乐播放器
  10. 那些配置修改之后需要重新启动