Problem--266A--Codeforces--Stones on the Table
来源:互联网 发布:淘宝宝贝描述规则 编辑:程序博客网 时间:2024/05/16 14:45
Stones on the Tables time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard outputThere are n stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row are considered neighboring if there are no other stones between them.
Input
The first line contains integer n (1 ≤ n ≤ 50) — the number of stones on the table.
The next line contains string s, which represents the colors of the stones. We’ll consider the stones in the row numbered from 1 to n from left to right. Then the i-th character s equals “R”, if the i-th stone is red, “G”, if it’s green and “B”, if it’s blue.Output
Print a single integer — the answer to the problem.Examples:
input
3
RRG
output
1input
5
RRRRR
output
4input
4
BRBG
output
0
#include<stdio.h>int main(){ int n,count=0; scanf("%d",&n); char stones[n+1]; scanf("%s",stones); for(int i=0;i<n-1;i++) { if(stones[i]==stones[i+1]) count++; } printf("%d\n",count); return 0;}
- Problem--266A--Codeforces--Stones on the Table
- CodeForces 266A Stones on the Table
- CodeForces-266A-Stones on the Table
- CodeForces 266A Stones on the Table
- codeforces 266A Stones on the Table
- 小白题解 Codeforces 266A Stones on the Table
- codeforces 266A(Stones on the Table) Java
- CodeForces 266 A.Stones on the Table(水~)
- CF - 266A - Stones on the Table
- 266A - Stones on the Table
- 266A - Stones on the Table
- CF 266A Stones on the Table
- A. Stones on the Table
- codeforces 266A Stones on the Table(模拟水题)
- Codeforces刷题之路——266A Stones on the Table
- A - Stones on the Table (hdu)
- Stones on the Table
- Stones on the Table
- 380. Insert Delete GetRandom O(1)
- 填坑日记2017.3.6
- 关于JAVA数组的几点注意事项与一些低级错误
- 十大排序算法
- Linux学习笔记-脚本(鸟哥13章)
- Problem--266A--Codeforces--Stones on the Table
- max nesting level reach '100'
- Android-动画-矢量动画技巧
- 轻松玩转正则表达式
- Linux学习日志(3)
- 弹出自定义输入框
- C++调用Python浅析
- 读书笔记 effective c++ Item 25 实现一个不抛出异常的swap
- 2014年北京Itcast-IOS4期视频教程