CodeForces - 344A Magnets (模拟题)
CodeForces - 344A
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 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 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 Output On the single line of the output print the number of groups of magnets. Sample Input
Input
6
Output
3
Input
4
Output
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 题意:依照顺序给你一个个磁铁,以及他们放置的位置: 比方说输入了01,10,01。10,10 则形成的排放为01 10 01 10 10。当中同性相斥,异性相吸,相吸的会连在一起形成一个快。如此。题目要求出有多少个块。
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
#include <cstdio> |
最新文章
- MySQL 子查询与连接操作笔记
- Java的多线程机制系列:(二)缓存一致性和CAS
- UIView动画
- Bootstrap_进度条
- C++学习基础二——指针与引用的区别
- webpack使用webpack-dev-middleware进行热重载
- (转)基于即时通信和LBS技术的位置感知服务(三):搭建Openfire服务器+测试2款IM客户端
- Linux中的终端、控制台、tty、pty等概念
- POJ 1404 I-Keyboard (DP)
- C#调用java接口报“Fault occurred while processing”异常问题
- 使用Volley StringRequest Get的方式进行发票查询操作
- [LeetCode] Decode String 题解
- Linux的nginx环境的vue 部署
- 初学node.js有感二
- 【SpringCloud】HystrixCommand的threadPoolKey默认值及线程池初始化
- ssh: connect to host github.com port 22: Connection timed out
- Java singleton 一例
- Visual Studio 2008 调试运行Bug记录
- 【DIV+CSS】代码作业练习DIV+CSS太极阴阳图
- OSI七层与tcp/ip四层