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 ...
随机推荐
- Subsequences in Substrings Kattis - subsequencesinsubstrings (暴力)
题目链接: Subsequences in Substrings Kattis - subsequencesinsubstrings 题目大意:给你字符串s和t.然后让你在s的所有连续子串中,找出这些 ...
- 调整JVM虚拟机的内存大小
jvm默认只有64M; public static void main(String[] args){ byte b[] = new byte[1024*1024*65];//此时会报内存溢出: } ...
- 假设程序需要一个int类型的变量来保持你所有的音乐CD的数量
假设程序需要一个int类型的变量来保持你所有的音乐CD的数量.初始值为0为该变量编写一条声明语句 int numCDs = 0;
- 代码编辑器 - Visual Studio Code
vscode的视图 1.Explorer 资源管理器 打开的编辑器:打开的正在编辑的文件,单击文件会覆盖前一个打开的文件tab,双击可使打开的文件并列显示 vue-server:你自己新建的项目目录, ...
- C# 锁
1.简介 锁是计算机协调多个进程或纯线程并发访问某一资源的机制.在数据库中,除传统的计算资源(CPU.RAM.I/O)的争用以外,数据也是一种供许多用户共享的资源.如何保证数据并发访问的一致性.有效性 ...
- 一个优秀windows C++ 程序员该有哪些知识
- C#实现邮件发送的功能
Ø 发送邮件所用的核心知识点 微软封装好的MailMessage类:主要处理发送邮件的内容(如:收发人地址.标题.主体.图片等等) 微软封装好的SmtpClient类:主要处理用smtp方式发送此邮 ...
- 题解-bzoj3569 DZY Loves Chinese II
Problem bzoj 题意概要:给定\(n\)点\(m\)边无向连通图,\(Q\)次询问删除\(k\)条边后是否仍然连通,强制在线 Solution 半年前考到过这类题目(询问删除任意两条边使得图 ...
- 题解-Codeforces710F String Set Queries
咕了好久没更博客,最近得知可以去冬眠营玩耍,还可以搭顺风车回广州过年 (最近做到的比较有意思的题目:bzoj3958.hihocoder1419) Problem Codeforces-710F--洛 ...
- 【转】Linux下gcc生成和使用静态库和动态库详解
一.基本概念 1.1 什么是库 在Windows平台和Linux平台下都大量存在着库. 本质上来说,库是一种可执行代码的二进制形式,可以被操作系统载入内存执行. 由于windows和linux的平台不 ...