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. linux下安装oracle11g 64位最简客户端(转)

    安装环境 Linux服务器:SuSe11 sp1 64位           Oracle客户端:Oracle11gR2 64位(最简客户端) 部署流程 1.准备工作,首先在oracle官网下载最新的 ...

  2. POJ 2485 Highways (prim最小生成树)

    对于终于生成的最小生成树中最长边所连接的两点来说 不存在更短的边使得该两点以不论什么方式联通 对于本题来说 最小生成树中的最长边的边长就是使整个图联通的最长边的边长 由此可知仅仅要对给出城市所抽象出的 ...

  3. jsp简单练习-简单的下拉表单

    <%@ page contentType="text/html; charset=gb2312" %> <html> <body> <fo ...

  4. Java Swing 树状组件JTree的使用方法(转)

    树中特定的节点可以由 TreePath(封装节点及其所有祖先的对象)标识,或由其显示行(其中显示区域中的每一行都显示一个节点)标识.展开 节点是一个非叶节点(由返回 false 的 TreeModel ...

  5. 好玩的WPF第二弹:电子表字体显示时间+多彩呼吸灯特效button

    我们先来看看Quartz MS字体动态显示系统时间的效果,难度相较于上一篇也要简单很多. 首先是定义一个TextBlock例如以下. <Grid> <TextBlock Name=& ...

  6. Extjs Web Desktop申请书

    今天我Web Desktop应用基本完成.多语言支持.现有asp,php,jsp版本号. 废话拍了几张照片让大家有一个直观的了解: watermark/2/text/aHR0cDovL2Jsb2cuY ...

  7. cocos2d-html5

    cocos2d-html5 简单的混乱 在正常情况下,build设置完毕后 跑ant编 变更后cocos2d.js 简单直观so easy 只需要上传cocos2d.js/game.js/index文 ...

  8. cassandra 服务启动流程

    cassandra 服务启动流程 1.  setup 1)   CassandraDaemon ->main publicstaticvoidmain(String[]args) { insta ...

  9. 【007】【JVM——内存分配和恢复策略】

     内存分配与收回策略 JVM的自己主动内存管理要自己主动化地解决两个问题:对象分配内存以及回收分配给对象的内存.回收内存前几篇已经讲了.如今说内存分配.对象的内存分配一般分配在堆内存中,也可能经过 ...

  10. 【Android进阶】Application对象的详解

    1:Application是什么? Application和Activity,Service一样,是android框架的一个系统组件,当android程序启动时系统会创建一个 application对 ...