zzu--2014年11月16日月潭赛 C称号
1230: Magnets
Time Limit: 1 Sec Memory Limit: 128 MB id=1230" style="color:rgb(26,92,200); text-decoration:none">Submit pid=1230" style="color:rgb(26,92,200); text-decoration:none">Web
Submit: 24 Solved: 13
[
Board
Description
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance,
then the like poles will repel each other and the opposite poles will attract each other.
Mike starts by laying one magnet horizontally on the table. During each following step Mike adds one more magnet horizontally to the right end of the row. Depending on how Mike puts the magnet on the table, it is either attracted to the previous one (forming
a group of multiple magnets linked together) or repelled by it (then Mike lays this magnet at some distance to the right from the previous one). We assume that a sole magnet not linked to others forms a group of its own.

Mike arranged multiple magnets in a row. Determine the number of groups that the magnets formed.
Input
The first line of the input contains an integer n (1 <= n <= 100000) ---- the
number of magnets. Then n lines follow. The i-th line
(1 <= i <= n) contains either characters "01",
if Mike put the i-thmagnet in the "plus-minus" position, or characters "10",
if Mike put the magnet in the "minus-plus" position.
Output
On the single line of the output print the number of groups of magnets.
Sample Input
Sample Output
HINT
The first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.
The second testcase has two groups, each consisting of two magnets.
Source
题意:就是去求一堆磁铁能分成几段!
大水题AC代码:
#include <stdio.h> int main()
{
char a[3];
int n;
while(scanf("%d", &n) != EOF)
{
scanf("%s", a);
n--;
char cur = a[1];
int ans=1;
while(n--)
{
scanf("%s", a);
if(a[0] == cur)
{
ans++;
cur = a[1];
}
}
printf("%d\n", ans);
}
return 0;
}
版权声明:本文博客原创文章,博客,未经同意,不得转载。
zzu--2014年11月16日月潭赛 C称号的更多相关文章
- zzu--2014年11月16日月潭赛 B称号
1229: Rational Resistance Time Limit: 1 Sec Memory Limit: 128 MB Submit: 8 Solved: 4 [id=1229" ...
- 11月16日《奥威Power-BI基于SQL的存储过程及自定义SQL脚本制作报表》腾讯课堂开课啦
上周的课程<奥威Power-BI vs微软Power BI>带同学们全面认识了两个Power-BI的使用情况,同学们已经迫不及待想知道这周的学习内容了吧!这周的课程关键词—— ...
- 2016年11月16日 星期三 --出埃及记 Exodus 20:7
2016年11月16日 星期三 --出埃及记 Exodus 20:7 "You shall not misuse the name of the LORD your God, for the ...
- CSDN下载频道2014年11月4日本-5日常维护公告
尊敬的用户: CSDN于2005年推出了下载服务.经过数年的发展.下载频道的用户已经为无数用户提供了帮助,分享500万的技术资源. CSDN下载频道将于2014年11月4日23点至11月5日8点进行积 ...
- 2014年11月17~11月18日,杨学明老师《企业IT需求收集和实施》内训在湖南长沙某酒店成功举办!
2014年11月17至18日,受湖南某软件企业的邀请,杨学明老师<企业IT需求收集和实施>内训在某长沙某五星级酒店成功举办!来自全国各地的IT高管和企业负责人参加了此次培训.杨学明老师分别 ...
- 2014年5月16至24日,杨学明老师为深圳创维RGB事业部提供两天的《软件测试管理》内训服务!
2014年5月16日和24日,<在软件开发流程中构筑软件质量—软件测试管理>内训课程在深圳创维集团成功举办!来自创维研发.测试.生产等部门的管理人员和核心骨干等参加了此次培训,此次培训由研 ...
- 北京Uber优步司机奖励政策(11月16日~11月22日)
用户组:人民优步“关羽组”(适用于11月16日-11月22日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/ ...
- OpenShare新功能@2014年11月 [2014-11-30]
新功能@Nov,2014 各门户层次主页布局自由编辑:升级为实时保存,这样用户编辑门户主页时,就算忘了点击“保存布局信息”,也不会丢失已做的工作 全方位支持匿名访问,支持构造公网以及extranet网 ...
- 2014年10月16号--for语句实例
Console.WriteLine("一对小兔一个月之后长成大兔,再过一个月后生新的一对兔子,且两年之后有多少对兔子,就是三兔子幼兔,小兔,成兔"); Console.WriteL ...
随机推荐
- Easy 2048 Again - ZOJ 3802 像缩进dp
Easy 2048 Again Time Limit: 2 Seconds Memory Limit: 65536 KB Dark_sun knows that on a single-tr ...
- sql dateDiff函数
当月的数据select * from MOPICK where dateDiff(m,getdate(),START_DATE)=0
- Python re正则表达式
参考: 博客园<Python正則表達式指南> 博客园<Python之re模块> 在此感谢博主的无私奉献,本文主要介绍python中re模块的几个简单使用方法.具体的使用方法请參 ...
- HDU 4284 状压dp+spfa
题意: 给定n个点 m条无向边 d元. 以下m行表示每条边 u<=>v 以及花费 w 以下top 以下top行 num c d 表示点标为num的城市 工资为c 健康证价格为d 目标是经过 ...
- 15一个NoSql数据库
随着因特网web2.0该网站的兴起.非关系型数据库,现在已经成为一个非常受欢迎的新领域.非关系数据库产品的发展非常迅速.而在处理传统的关系数据库web2.0现场.特别是大规模,高并发SNS类型web2 ...
- IntelliJ IDEA 问题总结之中的一个 —— jar包、assets、maven、git
因为工作须要,这几天開始弃用eclipse,换idea.用了几天,idea确实有些地方比較方便.可是麻烦也是不少.并且网上相应的资料并没有eclipse那么多,非常多都是自己琢磨解决的,所以想弄个帖子 ...
- iOS开发那些事-iOS6苹果地图有用开发
在iOS 6之后,不再使用谷歌地图了,而是使用苹果自己的地图,可是API编程接口没有太大的变化.开发者不须要再学习非常多新东西就能开发地图应用,这是负责任的做法.因此本节介绍的内容也相同适用于iOS5 ...
- C++ 习题 输出日期时间--友元函数
Description 设计一个日期类和时间类,编写display函数用于显示日期和时间.要求:display函数作为类外的普通函数,分别在Time和Date类中将display声明为友元函数.在主函 ...
- 如何区分MNO和MVNO
MVNO(Mobile Virtaul Network Operator)虚拟网络运营商,没有自己的物理网络,租用MNO(Mobile Network Operator)网络提供的网络服务. 我们知道 ...
- Android 角色时间戳
我是在用MediaRecorder进行录像时发生视频和音频不同步的问题,请教了一些人后感觉应该是没有时间戳,之前一直觉得时间戳就是给用户看的一个数据,查了一下发现不是的,以下是转载的.希望对大家实用: ...