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的更多相关文章

  1. BZOJ 2127: happiness [最小割]

    2127: happiness Time Limit: 51 Sec  Memory Limit: 259 MBSubmit: 1815  Solved: 878[Submit][Status][Di ...

  2. UVA 10498 Happiness(线性规划-单纯形)

    Description Prof. Kaykobad has given Nasa the duty of buying some food for the ACM contestents. Nasa ...

  3. CodeForces114E——Double Happiness(素数二次筛选)

    Double Happiness On the math lesson a teacher asked each pupil to come up with his own lucky numbers ...

  4. [置顶] [BZOJ]2127: happiness 最小割

    happiness: Description 高一一班的座位表是个n*m的矩阵,经过一个学期的相处,每个同学和前后左右相邻的同学互相成为了好朋友.这学期要分文理科了,每个同学对于选择文科与理科有着自己 ...

  5. 数学(线性规划):UVAoj 10498 Happiness

    Problem GHappiness! Input: standard inputOutput: standard outputTime Limit: 3 seconds Prof. Kaykobad ...

  6. [补档]happiness

    happiness 题目 传送门:http://cogs.pro/cogs/problem/problem.php?pid=1873 高一一班的座位表是个n×m的矩阵,经过一个学期的相处,每个同学和前 ...

  7. happiness[国家集训队2011(吴确)]

    [试题来源] 2011中国国家集训队命题答辩 [问题描述] 高一一班的座位表是个n*m的矩阵,经过一个学期的相处,每个同学和前后左右相邻的同学互相成为了好朋友.这学期要分文理科了,每个同学对于选择文科 ...

  8. 【BZOJ2127】happiness(最小割)

    [BZOJ2127]happiness(最小割) 题面 Description 高一一班的座位表是个n*m的矩阵,经过一个学期的相处,每个同学和前后左右相邻的同学互相成为了好朋友.这学期要分文理科了, ...

  9. 文理分科 BZOJ3894 & happiness BZOJ2127

    分析: 最小割(一开始我没看出来...后来经过提点,大致理解...),不选则割的思想. 我们先这样考虑,将和选理相关的和S相连,与选文相关的和T相连,如果没有第二问,那么建图就是简单的S连cnt,cn ...

随机推荐

  1. python(四)类变量和实例变量

    转载自[1] 实际这是个实例变量是否指向类变量的问题. python的类变量和实例变量,顾名思义,类变量是指跟类的变量,而实例变量,指跟类的具体实例相关联的变量,具体体现为self.x 等.实际要注意 ...

  2. HTML - CSS 基础篇

    网页主要由四部分组成: 1.内容(content) 图片.文本.多媒体等. 2.结构(structure) 框架布局(div+css布局的多行多列的结构.) 3.表现(presnetation) 修饰 ...

  3. Service生命周期

    https://www.cnblogs.com/huihuizhang/p/7623760.html (1)Service是单例的,只要没有destroy,多次startService或bindSer ...

  4. redis-set

    Java HashSet  无序,不重复. Redis操作中,涉及到两个大数据集合的并集,交集,差集运算. 赋值: sadd key values[value1.value2…]:向set中添加数据, ...

  5. [转载]Tensorflow 的reduce_sum()函数的axis,keep_dim这些参数到底是什么意思?

    转载链接:https://www.zhihu.com/question/51325408/answer/125426642来源:知乎 这个问题无外乎有三个难点: 什么是sum 什么是reduce 什么 ...

  6. Templates<2>

    Part:template specialized Part1:template specialized #include <iostream> #include <stdio.h& ...

  7. 【转】Python-面向对象进阶

    [转]Python-面向对象进阶 一.isinstance(obj, cls) and issubclass(sub, super) 1. isinstance(obj, cls),检查obj是否是类 ...

  8. 【转】MySQL用户管理及SQL语句详解

    [转]MySQL用户管理及SQL语句详解 1.1 MySQL用户管理 1.1.1 用户的定义 用户名+主机域 mysql> select user,host,password from mysq ...

  9. dubbo源码分析3——SPI机制中的ExtensionLoader类的objectFactory属性分析

    ExtensionLoader类是整个SPI的核心类,每个SPI都会对应一个ExtensionLoader类实例,这个类的构造方法如下: private ExtensionLoader(Class&l ...

  10. Statically Linking freeglut

    It’s possible statically link freeglut into your applications, instead of dynamically linking agains ...