【枚举计数】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;
}
#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;
}
相关文章推荐
- uva 294 - Divisors(枚举+计数)
- HDU 5701 中位数计数 (思维+枚举技巧)
- poj 3140 Contestants Division(树形dp? dfs计数+枚举)
- UVA 10574 - Counting Rectangles(枚举+计数)
- HDU 6052 To my boyfriend 思维 + 枚举(计数)
- [bzoj 1016] [JSOI2008]最小生成树计数:Kruskal,枚举
- poj 3140 Contestants Division(树形dp? dfs计数+枚举)
- 【经典dp】n数填m空,括号序列取第k项,最长非降序列计数及枚举,最短编辑距离
- 2013 多校第九场 hdu 4705 Y(枚举 + 树上的计数)
- poj 3140 Contestants Division(树形dp? dfs计数+枚举)
- 【枚举计数】HDU5995Kblack loves flag【BestCoder Round #90】
- UVA 10574 - Counting Rectangles(枚举+计数)
- codeforces #307 B. ZgukistringZ(枚举+计数)
- hdu6052 To my boyfriend (枚举计数)
- Polya 计数
- 枚举类型ENUM的使用
- 实例讲解Swift中引用类型的ARC自动引用计数
- 自定义类型:结构体,枚举,联合
- 一种基于引用计数机制的智能指针实现
- 使用枚举来实现单例模式