博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 5907 Find Q dp
阅读量:6968 次
发布时间:2019-06-27

本文共 976 字,大约阅读时间需要 3 分钟。

Find Q

题目连接:

Description

Byteasar is addicted to the English letter 'q'. Now he comes across a string S consisting of lowercase English letters.

He wants to find all the continous substrings of S, which only contain the letter 'q'. But this string is really really long, so could you please write a program to help him?

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 string S, it is guaranteed that S only contains lowercase letters and the length of S is no more than 100000.

Output

For each test case, print a line with an integer, denoting the number of continous substrings of S, which only contain the letter 'q'.

Sample Input

2

qoder
quailtyqqq

Sample Output

1

7

Hint

题意

问你有多少个子串,全部只含有q这个字母。

题解:

直接dp就好了,dp[i]表示以i结尾的方案数。

代码

#include
using namespace std;const int maxn = 100007;long long dp[maxn];void solve(){ string s; cin>>s; memset(dp,0,sizeof(dp)); for(int i=0;i

转载地址:http://wdbsl.baihongyu.com/

你可能感兴趣的文章
listview 重复动画效果
查看>>
Java中Runnable和Thread的区别
查看>>
04 - Object-C协议与代理设计
查看>>
PHP实现页面跳转
查看>>
在Android中取得当前进程名
查看>>
go http的按序号发送,按序号接收
查看>>
UML类图几种关系的总结
查看>>
Android手机主流屏幕分辨率有哪些?
查看>>
初探swift语言的学习笔记四(类对象,函数)
查看>>
drum
查看>>
easyui列统计
查看>>
Linux下配置JavaWeb环境(持续更新其他软件)
查看>>
Java之数组array和集合list、set、map
查看>>
Java异常了解
查看>>
管理员修改文件的权限
查看>>
Java注释@interface的用法
查看>>
桥接模式(Bridge)
查看>>
系统架构师具备的能力和构架师自我培养过程
查看>>
发布几个常用Docker基础环境镜像
查看>>
ThinkPad L412 安装Mac 10.7.2 显卡驱动安装成功
查看>>