codeforces Magnets
link:http://codeforces.com/contest/344/problem/A
这道题目很简单。
把输入的01 和10 当做整数,如果相邻两个数字相等的话,那么就属于同一组,否则,就新增加了一组。
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
int main(void)
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
int n;
while (~scanf("%d", &n))
{
int tmp;
;
;
while (n--)
{
scanf("%02d", &tmp);
if (tmp != pre) cnt++;
pre = tmp;
}
printf("%d\n", cnt);
}
;
}
==
其实,现在想那么多没用。其实……也想读研的,但是,又觉得没什么用……所以,很痛苦。
路在何方呢?在脚下?
codeforces Magnets的更多相关文章
- Codeforces Round #330 (Div. 1) C. Edo and Magnets 暴力
C. Edo and Magnets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/594/pr ...
- CodeForces - 344A Magnets (模拟题)
CodeForces - 344A id=46664" style="color:blue; text-decoration:none">Magnets Time ...
- Codeforces 344A Magnets
Description Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dom ...
- Codeforces 1345 D - Monopole Magnets
传送门:D. Monopole Magnets 这一场也是很神奇了,先是推迟三天,后是评测鸡崩了,unrated... 题意:每一行,每一列必须都要至少有一个s,n要可以到所有的黑格,n的上下左右如果 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
随机推荐
- JQuery随笔
web请求中,外部样式文件的加载不影响页面,js的加载会影响页面的加载速度 window.onlond 页面所有元素加载完后执行包含js,css等加载完毕 $(function(){}) 页面中DOM ...
- VisualSVN5.0.1补丁原创发布
VisualSVN5.0.1补丁原创发布
- 关于css样式2
css文本 CSS 文本属性可定义文本的外观. 通过文本属性,您可以改变文本的颜色.字符间距,对齐文本,装饰文本,对文本进行缩进,等等. 缩进文本 把 Web 页面上的段落的第一行缩进,这是一种最常用 ...
- js⑦
立即执行函数or自执行函数 为了避免全局变量的产生.(function(){ //var a = 10; //var b = 20;//console.log(a,b); -------------v ...
- atexit函数
使用该函数注册的退出函数是在进程正常退出时,才会被调用.这里强调是进程正常退出,使用exit退出或使用main中最后的return语句退出.但如果是因为收到信号signal而导致程序退出,如kill ...
- 用JAVA写查询一个字符串中是否包含另外一个字符串以及出现的次数
package JAVA; import java.awt.List;import java.util.ArrayList;/** * * @author 梁小鱼 * */public class ...
- mysql关于timestamp类型
数据库设置时间字段为timestamp类型,DTO设置为java.util.Date类型.DTO设值sessionLogDTO.setLoginOutTime(new Date());用new Dat ...
- oracle查询包含某个字段的表
select column_name,table_name,data_type ,data_length,data_precision,data_scale from DBA_TAB_COLUMNS ...
- [转载]盒模型display:-webkit-box;的使用
http://blog.sina.com.cn/s/blog_62161a4d01019b7g.html box-flex是css3新添加的盒子模型属性,它的出现可以解决我们通过N多结构.css实现的 ...
- WebSocket通信协议
var ws = new WebSocket("ws://echo.websocket.org"); ws.onopen = function(){ws.send("Te ...