http://codeforces.com/problemset/problem/556/A

题意:给一个01字符串,把所有相邻的0和1去掉,问还剩下几个0和1。

题解:统计所有的0有多少个,1有多少个,最后答案就是两者不同的个数。

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=;
char num[maxn];
int main()
{
int n,zero=,one=;
scanf("%d",&n);
scanf("%s",num);
for(int i=;i<n;i++){
if(num[i]=='') zero++;
if(num[i]=='') one++;
}
if(zero==one) printf("0\n");
else printf("%d\n",zero>one?zero-one:one-zero);
return ;
}

Codeforces Round #310 (Div. 2)--A(简单题)的更多相关文章

  1. Codeforces Round #599 (Div. 2)的简单题题解

    难题不会啊…… 我感觉写这个的原因就是因为……无聊要给大家翻译题面 A. Maximum Square 简单题意: 有$n$条长为$a_i$,宽为1的木板,现在你可以随便抽几个拼在一起,然后你要从这一 ...

  2. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  3. 构造 Codeforces Round #310 (Div. 2) B. Case of Fake Numbers

    题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少 ...

  4. 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones

    题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...

  5. Codeforces Round #609 (Div. 2)前五题题解

    Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...

  6. B. Case of Fake Numbers( Codeforces Round #310 (Div. 2) 简单题)

    B. Case of Fake Numbers time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. Codeforces Round #310 (Div. 2) B. Case of Fake Numbers 水题

    B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  8. Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones 水题

    A. Case of the Zeros and Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...

  9. Codeforces Round #310 (Div. 1) A. Case of Matryoshkas 水题

    C. String Manipulation 1.0 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

随机推荐

  1. Android ListView内容变化后的动态刷新

    ListView内容变化后的动态刷新 基本知识点: 1.更新适配器Adapter数据源 2.调用适配器Adapter的刷新方法notifyDataSetChanged() 首先需要定义ListView ...

  2. android:layout_weight详解

    参考; www.cnblogs.com/alpha-bowen/archive/2011/03/02/1969343.html 总结: 当需要对页面按比例分配时会用到这个选项: layout_weig ...

  3. bzoj1028

    穷举水题 ..] of boolean;     q:..] of longint;     ans,count,jud:..] of longint;     x,i,j,n,m,tot,t,k:l ...

  4. Linux下对拍脚本与随机数生成器

    对拍脚本 新建一个文档 check.sh 作为对拍脚本. #!/bin/bash while(true)do #死循环 ./data > .in #运行数据生成器,将数据输出到1.in ./st ...

  5. 使用表达式避免拼接SQL语句

    在SQL语句编写过程中,无论在存储过程中还是在程序中,有时为了使语句兼容全部情况与某字段的特殊情况,不得不拼接SQL字串 如下表 商品ID 类别ID 1 1 2 1 3 2 4 3 5 3 如果我们要 ...

  6. 编程之美 两个叶子的节点之间 最大距离 变种 leecode

    提交地址: https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/ 说一下思路http://www.cnblogs.com/mil ...

  7. zabbix邮件告警

    Zabbix邮件告警看了很多文档,写的那叫一个蛋疼,明明没有发出去邮件,硬要糊弄观众,我也跟着被糊弄. 操作系统环境: CentOS 5.5 x84_64位 Zabbix版本2.2.3 Web服务器: ...

  8. UVA 10194 Football (aka Soccer)

     Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (america ...

  9. crontab command not found

    在服务器上运行 crontab -e编辑定时任务 结果提示 command not found命令找不到,这就说明没安装crontab 由于 完整操作如下: [root@iZ11pvsxisqZ /] ...

  10. PAT 1012. The Best Rank

    To evaluate the performance of our first year CS majored students, we consider their grades of three ...