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 ...
随机推荐
- Python7 - 面向对象编程进阶
本节内容: 面向对象高级语法部分 经典式 VS 新式类 静态方法,类方法,属性方法 类的特殊方法 反射 异常处理 Socket开发基础 面向对象高级语法部分 经典类 VS 新式类 先看一串代码: cl ...
- Javascript入门(五)数组操作、循环语句
一.数组与数组操作 <script type="text/javascript"> //数组定义方式 var list1 = new Array(1,2,3); var ...
- POJ 1236 Network of Schools 连通图缩点
题目大意:有向图连通图,第一问求至少需要多少个软件才能传输到所有学校,第二问求至少需要增加多少条路使其成为强连通图 题目思路:利用Tarjan算法经行缩点,第一问就是求缩点后入度为0的点的个数(特殊情 ...
- 【Java编程思想笔记】-集合1
1.为什么要用集合? 一般情况下,数组是保存一组对象(或基本数据类型)最有效的方式.但是数组有着固定的尺寸,而在更一般的情况下,我们在写程序时不知道将需要保存多少个对象,或者是否需要更复杂的存储结构来 ...
- yum upgrade和yum update的区别
Linux升级命令有两个分别是yum upgrade和yum update, 这个两个命令是有区别的: yum -y update 升级所有包同时也升级软件.系统版本和系统内核 yum -y upgr ...
- 匿名内部类可以访问的变量---静态成员变量和final修饰的局部变量
在学习多线程的时候用到了匿名内部类,匿名内部类可以访问static静态成员变量或者final修饰的局部变量. 匿名内部类在编译之后会生成class文件,比如Test内的第一个匿名内部类编译之后就是Te ...
- 20165325 2017-2018-2 《Java程序设计》 第八周学习总结
一.教材学习笔记 ch12 1.程序是一段静态的代码,进程是程序的一次动态执行过程 2.线程比进程还小,一个进程的进行期间可以产生多个线程. 3.Java内置对多线程的支持.我们的计算机在任何给定说的 ...
- Scala 特质全面解析
要点如下: Scala中类只能继承一个超类, 可以扩展任意数量的特质 特质可以要求实现它们的类具备特定的字段, 方法和超类 与Java接口不同, Scala特质可以提供方法和字段的实现 当将多个特质叠 ...
- dubbo源码分析14——DubboProtocol的export方法分析
走到了这一步也挺不容易的,把之前的暴露入口代码再列出来回顾一下: //配置为none不暴露 if (! Constants.SCOPE_NONE.toString().equalsIgnoreCase ...
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data错误的解决
记录个报错: 问题描述: 经过服务器生成图片返到前台时,在火狐浏览器中下载图片或打开图片时报错:SyntaxError: JSON.parse: unexpected character at lin ...