Happiness
1575: Happiness
时间限制: 1 Sec 内存限制: 1280 MB
题目描述
Chicken brother is very happy today, because he attained N pieces of biscuits whose tastes are A or B. These biscuits are put into a box. Now, he can only take out one piece of biscuit from the box one time. As we all know, chicken brother is a creative man. He wants to put an A biscuit and a B biscuit together and eat them. If he take out an A biscuit from the box and then he take out a B biscuit continuously, he can put them together and eat happily. Chicken brother’s happiness will plus one when he eat A and B biscuit together one time.
Now, you are given the arrangement of the biscuits in the box(from top to bottom) ,please output the happiness of Chicken Brother when he take out all biscuit from the box.
输入
The first line is an integer indicates the number of test cases.
In each case, there is one line includes a string consists of characters ‘A’ and ‘B’.
The length of string is not more than 1000000.
输出
For each test case:
The first line output “Case #k:", k indicates the case number.
The second line output the answer.
样例输入
1 ABABBBA
样例输出
Case #1: 2
解题思路
水题。
#include <stdio.h> #include <string.h> char str[1000010]; int main() { int t, count, len; scanf("%d", &t); for (int i = 1; i <= t; i++) { count = 0; scanf("%s", str); len = strlen(str); for (int j = 1; j < len; j++) { if (str[j - 1] == 'A' && str[j] == 'B') count++; } printf("Case #%d:\n%d\n",i, count); } return 0; }
Happiness的更多相关文章
- BZOJ 2127: happiness [最小割]
2127: happiness Time Limit: 51 Sec Memory Limit: 259 MBSubmit: 1815 Solved: 878[Submit][Status][Di ...
- UVA 10498 Happiness(线性规划-单纯形)
Description Prof. Kaykobad has given Nasa the duty of buying some food for the ACM contestents. Nasa ...
- CodeForces114E——Double Happiness(素数二次筛选)
Double Happiness On the math lesson a teacher asked each pupil to come up with his own lucky numbers ...
- [置顶] [BZOJ]2127: happiness 最小割
happiness: Description 高一一班的座位表是个n*m的矩阵,经过一个学期的相处,每个同学和前后左右相邻的同学互相成为了好朋友.这学期要分文理科了,每个同学对于选择文科与理科有着自己 ...
- 数学(线性规划):UVAoj 10498 Happiness
Problem GHappiness! Input: standard inputOutput: standard outputTime Limit: 3 seconds Prof. Kaykobad ...
- [补档]happiness
happiness 题目 传送门:http://cogs.pro/cogs/problem/problem.php?pid=1873 高一一班的座位表是个n×m的矩阵,经过一个学期的相处,每个同学和前 ...
- happiness[国家集训队2011(吴确)]
[试题来源] 2011中国国家集训队命题答辩 [问题描述] 高一一班的座位表是个n*m的矩阵,经过一个学期的相处,每个同学和前后左右相邻的同学互相成为了好朋友.这学期要分文理科了,每个同学对于选择文科 ...
- 【BZOJ2127】happiness(最小割)
[BZOJ2127]happiness(最小割) 题面 Description 高一一班的座位表是个n*m的矩阵,经过一个学期的相处,每个同学和前后左右相邻的同学互相成为了好朋友.这学期要分文理科了, ...
- 文理分科 BZOJ3894 & happiness BZOJ2127
分析: 最小割(一开始我没看出来...后来经过提点,大致理解...),不选则割的思想. 我们先这样考虑,将和选理相关的和S相连,与选文相关的和T相连,如果没有第二问,那么建图就是简单的S连cnt,cn ...
随机推荐
- Django REST framework 第一章 Serialization
此章节将会介绍多种构成REST framework的重要模块,在每个部分如何一起配合上提供一个综合的全方面的了解. 准备 同样的创建一个新项目,创建一个新的app,将rest_framework跟新建 ...
- 爬虫BS4—淘女郎
1.修改网页头 用独自的py文件getheaders,随机返回header getheaders文件 import random headerstr = """Mozil ...
- Trades FZU - 2281 (贪心)(JAVA)
题目链接: J - Trades FZU - 2281 题目大意: 开始有m个金币, 在接下来n天里, ACMeow可以花费ci金币去买一个物品, 也可以以ci的价格卖掉这个物品, 如果它有足够的金 ...
- linux 备份与恢复
- 一张图片资源要占用多大内存xhdpi xxhdpi
一张图片资源要占用多大内存,可以用下面的计算公式计算 4 * withPixel*(targetDensity /sourcedensity) * heightPixel*(targetDensity ...
- ASP.NET MVC - 安全、身份认证、角色授权和ASP.NET Identity
ASP.NET MVC - 安全.身份认证.角色授权和ASP.NET Identity ASP.NET MVC内置的认证特性 AuthorizeAttribute特性(System.Web.Mvc)( ...
- MySql cmd下的学习笔记 —— 有关select的操作(order by,limit)
先选择goods表 set names gbk; 把本店价从低到高排序(order by) (注意)order by 要放在where, group by, having之后 查询本店价从高到低排序 ...
- scrapy基础 之 爬虫入门:先用urllib2来跑几个爬虫
1,爬取糗事百科 概况:糗事百科是html网页,支持直接抓取html字符然后用正则过滤 爬取糗事百科需要同时发送代理信息,即user-agent import urllib2,re def pacho ...
- ActiveMQ常见消息类型
JMS由下面三部分组成:消息头.属性.消息体.其中消息体定义了五种消息体格式,也可以称为消息类型. JMS规范中的消息类型包括TextMessage.MapMessage.ObjectMessage. ...
- SpringBoot2.0+ DataSourceInitializer不生效的问题
1.在url后声明时区 2.更换mysql6.0+的驱动 3.配置属性initialization-mode 为 always 我就是这样解决问题的,如果没解决的话,请在留言处指出错误.谢谢