您的位置:首页 > 其它

【枚举计数】HDU5907Find Q【BestCoder Round #88】

2017-08-12 12:58 183 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5907

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
string s;
cin.sync_with_stdio(false);
cin>>t;
while(t--){
cin>>s;
int len=s.size();
int cnt=0;
long long ans=0;
for(int i=0;i<len;i++){
if(s[i]=='q'){
cnt++;
ans+=cnt;
}else{
cnt=0;
}
}
cout<<ans<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  BestCoder