hdu----Find Q
来源:互联网 发布:淘宝店铺添加客服 编辑:程序博客网 时间:2024/05/17 22:22
Byteasar is addicted to the English letter 'q'. Now he comes across a stringS consisting of lowercase English letters.
He wants to find all the continous substrings ofS , which only contain the letter 'q'. But this string is really really long, so could you please write a program to help him?
He wants to find all the continous substrings of
Input
The first line of the input contains an integer T(1≤T≤10) , denoting the number of test cases.
In each test case, there is a stringS , it is guaranteed that S only contains lowercase letters and the length of S is no more than 100000 .
In each test case, there is a string
Output
For each test case, print a line with an integer, denoting the number of continous substrings ofS , which only contain the letter 'q'.
Sample Input
2qoderquailtyqqq
Sample Output
1
7
题意:给出一串字符串S,问S中的仅包含字母q的连续子串有几个
#include<cstdio>#include<cstring>char a[100005];int main(){ int n; long long sum,ans; scanf("%d",&n); while(n--) { ans=sum=0; scanf("%s",a); int len=strlen(a); for(int i=0; i<=len; i++) { if(a[i]=='q') sum++; else { ans+=(sum+1)*sum/2; sum=0; } } printf("%lld\n",ans); } return 0;}
阅读全文
0 0
- hdu 5907 Find Q
- HDU 5907 Find Q
- HDU 5907 Find Q
- HDU:5907 Find Q
- hdu 5907 Find Q
- HDU 5907 Find Q
- find q hdu
- HDU 5907 Find Q
- hdu----Find Q
- hdu 5907 Find Q【模拟】
- 【50.26%】【hdu 5907】Find Q
- HDU 5907 Find Q dp
- HDU 5904 BestCoder Round #88 Find Q (统计Q!)
- HDU:5907 Find Q(水题)
- Find Q HDU——5907
- Find Q
- Find Q
- Find Q
- 查看opencv源码
- 借鉴prototype.js实现继承
- unordered_map
- ubuntu 安装不了软件
- Java垃圾回收机制
- hdu----Find Q
- SharedPerference
- 字段
- Python 边做边学 2 准备工作
- (转)来自瑞士的七个葫芦娃:各怀绝技的Wealthtech解决方案商
- Win10+python2.7.6+opencv2.4.13环境下, 调用cv2.VideoCapture()失败的解决方法
- 小波系数的理解
- 简单的创建socket和连接
- keras学习笔记