找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones
/*
找规律/贪心:ans = n - 01匹配的总数,水
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; const int MAXN = 2e5 + ;
const int INF = 0x3f3f3f3f;
char s[MAXN]; int main(void) //Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones
{
// freopen ("A.in", "r", stdin); int n;
while (scanf ("%d", &n) == )
{
scanf ("%s", s);
int cnt_0 = , cnt_1 = ;
for (int i=; i<n; ++i)
{
if (s[i] == '') cnt_0++;
else cnt_1++;
} printf ("%d\n", n - min (cnt_0, cnt_1) * );
} return ;
}
找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones的更多相关文章
- 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 ...
- 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...
- 构造 Codeforces Round #310 (Div. 2) B. Case of Fake Numbers
题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少 ...
- 数学/找规律/暴力 Codeforces Round #306 (Div. 2) C. Divisibility by Eight
题目传送门 /* 数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案:用到sprintf把数字转移成字符读入 */ #include <cstdio> #include <a ...
- 【找规律】Codeforces Round #392 (Div. 2) C. Unfair Poll
C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #310 (Div. 1) B. Case of Fugitive set
B. Case of Fugitive Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/p ...
- Codeforces Round #310 (Div. 1) C. Case of Chocolate set
C. Case of Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/ ...
- 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 ...
- 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 ...
随机推荐
- Linux OpenSSH后门的加入与防范
引言:相对于Windows,Linux操作系统的password较难获取.只是非常多Linuxserver配置了OpenSSH服务.在获取root权限的情况下,能够通过改动或者更新OpenSSH代码等 ...
- udhcp源码详解(一)之文件组织结构(dhcp server) --转
udhcp目录下有十几个源文件,一个源文件相对应一个模块,完成一系列相关的功能,例如在static_leases.c主要针对static_lease链表增删查找等操作. dhcpd.c—— 整个d ...
- css3最新版中文参考手册在线浏览
对于CSS 3.0,它对于我们Web设计人员来说不只是新奇的技术,更重要的是这些全新概念的Web应用给我们的设计开发提高了效率以及更多的无限可能性,我们将不必再依赖图片或者 Javascript 去完 ...
- 嵌入式开发之davinci---DM8168 8127 8148 HDVPSS中的一些英文缩写解释
BLEND:Alpha blends input with the graphics.将输入的视频与图形做Alpha融合. CPROC:Color Processing.颜色处理.如动态对比度增强.饱 ...
- 解决input,number类型的maxlength无效
使用input数字number类型的时候maxlength无效,假设需要控制输入数量为5,可以用以下方式: 无效: <input type="text" maxlength ...
- <s:property>的用法(jsp获取action中的值或者方法)
1,访问Action值栈中的普通属性: <s:property value="attrName"/> 2,访问Action值栈中的对象属性(要有get set方法) ...
- Interpret bytes as packed binary data
7.1. struct — Interpret bytes as packed binary data — Python 3.6.5 documentation https://docs.python ...
- UESTC 982质因子分解
读入一个自然数,将nn分解为质因子连乘的形式输出. Input 有多组测试数据.输入的第一行是整数TT(0<T≤10000),表示测试数据的组数.每一组测试数据只有一行,包含待分解的自然数nn. ...
- jQuery 与 AJAX 实现失去焦点验证用户名是否合格
JSP页面 <tr onmouseover="currentcolor=this.style.backgroundColor;this.style.backgroundColor='# ...
- linux环境下oracle静默安装
一.安装环境 1.linux版本:redhat6.3_x86_64 2.oracle版本:Oracle Database 11g Enterprise Edition Release 11.2.0.3 ...