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 ...
随机推荐
- 《Java编程思想第四版》附录 B 对比 C++和 Java
<Java编程思想第四版完整中文高清版.pdf>-笔记 附录 B 对比 C++和 Java “作为一名 C++程序员,我们早已掌握了面向对象程序设计的基本概念,而且 Java 的语法无疑是 ...
- 假设result 是一个float型变量,value是一个int型变量。执行以下赋值语句以后,变量value将是什么类型?为什么?
假设result 是一个float型变量,value是一个int型变量.执行以下赋值语句以后,变量value将是什么类型?为什么? 在执行这条语句的过程中,保存在vulue变量中的值被读取出来并转化为 ...
- python读取两个文件并且判断是否一致
''' 判断两个文件是否相同,如果不同请指出第几行不相同 ''' def f1vsf2(name1,name2): f1 = open(name1) f2 = open(name2) count = ...
- QR 编码原理(二)
编码就是把常见的数字.字符等转换成QR码的方法.说具体的编码之前,先说一下QR码的最大容量问题. 一.最大容量 QR码的最大容量取决于选择的版本.纠错级别和编码模式(Mode:数字.字符.多字节字符等 ...
- 20165231 2017-2018-2 《Java程序设计》第6周学习总结
教材学习内容总结 第八章 String类 Java专门提供了用来处理字符序列的String类. String类在java.lang包中,由于java.lang包中的类被默认引入,因此程序可以直接使用S ...
- Deep Learning Tutorial - Classifying MNIST digits using Logistic Regression
Deep Learning Tutorial 由 Montreal大学的LISA实验室所作,基于Theano的深度学习材料.Theano是一个python库,使得写深度模型更容易些,也可以在GPU上训 ...
- Mac 远程桌面 ubuntu16.04 unity
待解决问题: 使用 vnc 远程桌面 ubunt16.04的自带桌面 unity 尝试方法 : 查看了各种方法, 基本都是曲线救国, 安装 gnome 或者 xfce4等其他桌面系统, 而我只想用好看 ...
- python3+selenium框架设计01-Page Object
页面对象模型Page Object Modal是一种脚本设计模型,将页面元素,业务操作分割,当实际页面发生变化的时候,只需要修改页面元素文件,业务操作不需要修改. 具体实现需要先写一个页面公共类,里面 ...
- SQL Server Profiler 常见问题总结
1.跟踪指定数据库 SELECT DB_ID('数据名称') 原文:https://jingyan.baidu.com/article/647f0115be128a7f2048a87d.html 2. ...
- IOT相关协议
MQTT协议的入门 入门教程; 发布/订阅(Pub/Sub)模式,方便消息在传感器之间传递; 这意味着发布者和订阅者之间并不需要直接建立联系; 消息类型 MQTT拥有14种不同的消息类型: CONNE ...