CodeForces 266A Stones on the Table
来源:互联网 发布:unity3d 捏脸系统 编辑:程序博客网 时间:2024/05/17 07:11
A. Stones on the Table
time limit per test
2 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard 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 from1 to n from left to right. Then thei-th character s equals "R", if thei-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.
Sample test(s)
Input
3RRG
Output
1
Input
5RRRRR
Output
4
Input
4BRBG
Output
0#include<stdio.h>int main(){ int n,i; char a[60]; while(scanf("%d",&n)!=EOF){ scanf("%s",a); int j=0; for(i=0;i<n;i++){ if(a[i]==a[i-1]){ j++; } } printf("%d\n",j); } return 0;}
0 0
- CodeForces 266A Stones on the Table
- CodeForces-266A-Stones on the Table
- CodeForces 266A Stones on the Table
- codeforces 266A Stones on the Table
- Problem--266A--Codeforces--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
- 分页效果
- poj3461—KMP裸题
- Map的遍历方式
- cocos2dx[3.2]——裁剪节点ClippingNode
- poj2406—KMP next数组的性质求最小周期
- CodeForces 266A Stones on the Table
- QT选择文件对话框实现多种类型文件匹配过滤
- JavaWeb — HTML
- iOS中使用RegexKitLite来试用正则表达式 使用ARC 20个错误解决办法
- 245,键盘处理
- SHUOJ 1013 过河卒问题 (递推)
- The Java™ Tutorials — Concurrency :Defining and Starting a Thread 线程的定义和启动
- 原子位操作
- 597C. Subsequences【DP】【树状数组】