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 12 - Mysql & ORM

    本节内容 1.数据库介绍 2.mysql数据库安装使用 3.mysql数据库基础 4.mysql命令 5.事务 6.索引 7.Python操作mysql 8.ORM sqlalchemy了解 数据库介 ...

  2. POJ 1236 Network of Schools 连通图缩点

    题目大意:有向图连通图,第一问求至少需要多少个软件才能传输到所有学校,第二问求至少需要增加多少条路使其成为强连通图 题目思路:利用Tarjan算法经行缩点,第一问就是求缩点后入度为0的点的个数(特殊情 ...

  3. IDEA在同一窗口导入多个项目

    在同一窗口打开多个项目 1. 当前窗口: 2. 3.  选择import module即可.然后一直点击next导入OK即可. 同一窗口目录下创建多个项目 1.File→New→Module 2.Ja ...

  4. springboot中使用过滤器、拦截器、监听器

    监听器:listener是servlet规范中定义的一种特殊类.用于监听servletContext.HttpSession和servletRequest等域对象的创建和销毁事件.监听域对象的属性发生 ...

  5. JDK源码笔记--Object

    public final native Class<?> getClass(); public native int hashCode(); public boolean equals(O ...

  6. Python笔记 【无序】 【一】

    ----------- r'原始数据'                                                            为了输入[c:\n\d\r\] 代码:   ...

  7. 【keepalived】CentOS7.0下安装教程

    安装前所需环境 keepalived安装之前,需要环境:wget.gcc.pcre.openssl.zlib.popt-devel 1,wget:用于从外网上下载插件 wget安装命令:yum -y ...

  8. asyncio之asyncio.run

    asyncio.run(coro, *, debug=False) python3.7加入,只能作为asyncio的入口函数.

  9. Git学习笔记05-撤销修改

    使用 git checkout -- file可以撤销工作区的修改 一种是修改后还没有放到暂存区,撤销修改回到和版本库一模一样的状态 lesson.txt文件已经提交到版本库了,内容如图. ​ 修改一 ...

  10. Qt5全局热键第三方库qxtglobalshortcut5使用

    1.下载第三方库https://github.com/ddqd/qxtglobalshortcut5. 2.把qxtglobalshortcut5文件放在项目目录下,在项目.pro加入一句,inclu ...