1230: Magnets

Time Limit: 1 Sec  Memory Limit: 128 MB

Submit: 24  Solved: 13

[

id=1230" style="color:rgb(26,92,200); text-decoration:none">Submit][Status][

pid=1230" style="color:rgb(26,92,200); text-decoration:none">Web
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

6
10
10
10
01
10
10
4
01
01
10
10

Sample Output

3
2

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

CF

题意:就是去求一堆磁铁能分成几段!



大水题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称号的更多相关文章

  1. zzu--2014年11月16日月潭赛 B称号

    1229: Rational Resistance Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 8  Solved: 4 [id=1229" ...

  2. 11月16日《奥威Power-BI基于SQL的存储过程及自定义SQL脚本制作报表》腾讯课堂开课啦

           上周的课程<奥威Power-BI vs微软Power BI>带同学们全面认识了两个Power-BI的使用情况,同学们已经迫不及待想知道这周的学习内容了吧!这周的课程关键词—— ...

  3. 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 ...

  4. CSDN下载频道2014年11月4日本-5日常维护公告

    尊敬的用户: CSDN于2005年推出了下载服务.经过数年的发展.下载频道的用户已经为无数用户提供了帮助,分享500万的技术资源. CSDN下载频道将于2014年11月4日23点至11月5日8点进行积 ...

  5. 2014年11月17~11月18日,杨学明老师《企业IT需求收集和实施》内训在湖南长沙某酒店成功举办!

    2014年11月17至18日,受湖南某软件企业的邀请,杨学明老师<企业IT需求收集和实施>内训在某长沙某五星级酒店成功举办!来自全国各地的IT高管和企业负责人参加了此次培训.杨学明老师分别 ...

  6. 2014年5月16至24日,杨学明老师为深圳创维RGB事业部提供两天的《软件测试管理》内训服务!

    2014年5月16日和24日,<在软件开发流程中构筑软件质量—软件测试管理>内训课程在深圳创维集团成功举办!来自创维研发.测试.生产等部门的管理人员和核心骨干等参加了此次培训,此次培训由研 ...

  7. 北京Uber优步司机奖励政策(11月16日~11月22日)

    用户组:人民优步“关羽组”(适用于11月16日-11月22日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/ ...

  8. OpenShare新功能@2014年11月 [2014-11-30]

    新功能@Nov,2014 各门户层次主页布局自由编辑:升级为实时保存,这样用户编辑门户主页时,就算忘了点击“保存布局信息”,也不会丢失已做的工作 全方位支持匿名访问,支持构造公网以及extranet网 ...

  9. 2014年10月16号--for语句实例

    Console.WriteLine("一对小兔一个月之后长成大兔,再过一个月后生新的一对兔子,且两年之后有多少对兔子,就是三兔子幼兔,小兔,成兔"); Console.WriteL ...

随机推荐

  1. Windows Phone 如果你把Pivot控件当成主页面,那么这篇文章你值得看。

    原文:Windows Phone 如果你把Pivot控件当成主页面,那么这篇文章你值得看. 现在很多App都用到了Pivot视图 来当作 整个App主页面.如果你的Pivot视图主页面承载了大量数据的 ...

  2. WebPack实例与前端性能优化

    [前端构建]WebPack实例与前端性能优化   计划把微信的文章也搬一份上来. 这篇主要介绍一下我在玩Webpack过程中的心得.通过实例介绍WebPack的安装,插件使用及加载策略.感受构建工具给 ...

  3. OpenStack_Swift源代码分析——Ring基本原理及一致性Hash算法

    1.Ring的基本概念 Ring是swfit中最重要的组件.用于记录存储对象与物理位置之间的映射关系,当用户须要对Account.Container.Object操作时,就须要查询相应的Ring文件( ...

  4. shell文字过滤程序(十):cut命令

    [版权声明:转载请保留源:blog.csdn.net/gentleliu.Mail:shallnew at 163 dot com] cut指挥类似至awk,从行内提取的信息,它是一个较弱的版本的功能 ...

  5. [原创] linux 下上传 datapoint数据到yeelink 【golang版本】

    package main /* Create by sndnvaps<sndnvaps@gmail.com> * date : 2015-04-05 * upload datapoint ...

  6. 【原创】纯OO:从设计到编码写一个FlappyBird (六)

    第五部分请看这里 终于到了最后一个部分了! 这里使用SimpleJudge类来实现Judge接口. 首先是SimpleJudge需要的实例变量: 0.final LinkedList<Pilla ...

  7. ios-html-get/post差额,简而言之(MS)CheckST

    get直接采取拉数据,post注射剂server.至server安全或使用get 而且由于get明确传递,password帐户A眼可以看得出来,甚至加密也可以很easy解,所以传password用po ...

  8. PHP扩展memcache模

    研究yii当配套部件,发现自己PHP甚至不支持memcache该模块,于是,我就展开位. 本机环境:win8.1 开发环境:php 5.5  第一步:先把所需的文件包下载全然,我已经打包好,这里能够下 ...

  9. Hdu 3341 Lost&#39;s revenge (ac+自己主动机dp+hash)

    标题效果: 举个很多种DNA弦,每个字符串值值至1.最后,一个长字符串.要安排你最后一次另一个字符串,使其没事子值和最大. IDEAS: 首先easy我们的想法是想搜索的!管她3721..直接一个字符 ...

  10. DHCP Option 60 认识

    原文地址: http://blog.163.com/chenqioulin_1983/blog/static/83216232010109104430251/   首先还是看看RFC咋说的吧.DHCP ...