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> |
CodeForces - 344A Magnets (模拟题)的更多相关文章
- Codeforces 344A Magnets
Description Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dom ...
- Codeforces 749C. Voting 模拟题
C. Voting time limit per test: 1 second memory limit per test: 256 megabytes input: standard input o ...
- CodeForces - 427B (模拟题)
Prison Transfer Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Sub ...
- Educational Codeforces Round 2 A. Extract Numbers 模拟题
A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...
- Codeforces 767B. The Queue 模拟题
B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...
- Codeforces Beta Round #7 B. Memory Manager 模拟题
B. Memory Manager 题目连接: http://www.codeforces.com/contest/7/problem/B Description There is little ti ...
- Codeforces Beta Round #5 B. Center Alignment 模拟题
B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...
- Codeforces Beta Round #3 C. Tic-tac-toe 模拟题
C. Tic-tac-toe 题目连接: http://www.codeforces.com/contest/3/problem/C Description Certainly, everyone i ...
- Codeforces Gym 100269B Ballot Analyzing Device 模拟题
Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...
随机推荐
- thinkphp data方法
data方法也是模型类的连贯操作方法之一,用于设置当前要操作的数据对象的值,可能大家不太习惯用这个方法,今天来讲解下如何用好data方法. 用法 写操作 通常情况下我们都是通过create方法或者赋值 ...
- AFN上传多张图片
AFN上传多张图片代码: AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager]; sessionManager.r ...
- php获取当地时间 time zone
PHP5.2.4之前的版本无需设置时区.下面是修改PHP时区的三个办法. 1.修改PHP.ini这个文件 找到date.timezone这行,去掉前面的分号,改成: Java代码 date.tim ...
- 【Oracle】DG中物理备库、快照备库的相互转换
一.物理备库切换快照备库 1. 如果正在运行日志应用,先停止 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; 2. 确保数据库为MOUN ...
- 解决 C# webbrowser 弹出json下载问题
把以下内容保存为 .reg ,然后导入注册表,即可解决C# webbrowser 弹出json下载问题,也可通过程序修改. Windows Registry Editor Version 5.00 [ ...
- php xss 函数
function xss($string) { if (is_array($string)||is_object($string)||is_resource($string)) { return '' ...
- spring学习地址
http://developer.51cto.com/art/201006/205212_2.htm
- PAT_A1076#Forwards on Weibo
Source: PAT A1076 Forwards on Weibo (30 分) Description: Weibo is known as the Chinese version of Twi ...
- Axure RP 9 WIN10 64位安装步骤及注册码
License栏输入:ABC Key栏输入:M5PHzBHvhAG3cNRr2CFxAJaIHaXOkwleDSctQ9sY0pQ2vd7eJzoBNtD7zBZNSPmT http://www.zh ...
- C#datetime判断日期输入是否正确
//7.输入年月日,看看格式是否正确.利用DateTime. //(1) //DateTime dt=DateTime.Now; //Console.Write("请输入现在的年:" ...