codeforces 1549B. Gregor and the Pawn Game
题意
链接: link.
思路
贪心即可
AC代码
#include <bits/stdc++.h>
using namespace std;
string u;
string d;
int main()
{int t;cin >> t;while (t--){int n;cin >> n;cin >> u;cin >> d;u = "0" + u;u += "0";d = "0" + d;int res = 0;for (int i = 1; i <= n; i++){if (d[i] == '1'){if (u[i - 1] == '1'){u[i - 1] = '0';res++;}else if (u[i] == '0'){res++;}else if (u[i + 1] == '1'){u[i + 1] = '0';res++;}}}cout << res << endl;}//system("pause");return 0;
}
codeforces 1549B. Gregor and the Pawn Game相关推荐
- CodeForces - 1549F1 Gregor and the Odd Cows (Easy)(几何+数论)
题目链接:点击查看 题目大意:给出二维平面上的 nnn 个点,任意选择出三个点可以构成一个三角形,现在问满足下面条件的三角形的个数: 三角形面积为整数 三角形包含的(不包括边界)整数点为奇数 其中所有 ...
- Codeforces Round #736 (Div. 1Div2)
Codeforces Round #736 (Div2) Codeforces Round #736 (Div. 1) 题号 题目 难度 A Gregor and Cryptography 签到 B ...
- codeforces:ProblemMset
最近一个月在codeforces上做的题(做个记录) 后面太多了就不把代码一一放出了,只放置了链接,可根据链接找到提交的代码. 最小子矩阵 #include <iostream> #inc ...
- CF杂题训练(交互题不做,2500以上的看情况吧)
CF专练 CF1562 A The Miracle and the Sleeper B Scenes From a Memory C Rings D Two Hundred Twenty One E ...
- Codeforces 41D Pawn 简单dp
题目链接:点击打开链接 给定n*m 的矩阵 常数k 以下一个n*m的矩阵,每一个位置由 0-9的一个整数表示 问: 从最后一行開始向上走到第一行使得路径上的和 % (k+1) == 0 每一个格子仅仅 ...
- Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess DP
C. Gerald and Giant Chess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...
- 2016-2017 CT S03E06: Codeforces Trainings Season 3 Episode 6(8/13)
2016-2017 CT S03E06: Codeforces Trainings Season 3 Episode 6 比赛连接: http://codeforces.com/gym/101124/ ...
- 【11.9】Codeforces 刷题
DP\text{DP}DP : B. Yaroslav and Two Strings 题意: 如果两个只包含数字且长度为 n(1≤n≤105)n(1\leq n\leq 10^5)n(1≤n≤105 ...
- CodeForces 375D Tree and Queries
传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...
- 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)
题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...
最新文章
- 道器相融,由Angel论一个优秀机器学习平台的自我修养
- java对象的内存分配
- Object.prototype.toString.call()检测
- ThreadLocal原理及用法详解
- python中最大值最小值平均值_来自lis的Python平均值、最大值、最小值
- 获得SAP help center的url
- php面向对象引用文件,PHP面向对象之对象和引用
- java replaceall函数_JAVA中string.replace和string.replaceAll的区别及用法
- 一些常用的meta标签及其作用
- 清华镜像站 python_使用清华、豆瓣镜像源下载tensorflow
- oracle中imp命令具体解释
- 如何搞定纸上代码环节?
- 24 内置函数 命名元组(namedtuple) ,os ,sys,序列化,pickle,json
- 利用全加器实现7段数码管_单片机入门,8个led数码管精选电路方案合辑
- SQLMAP简易使用教程
- linux 查找pcre源码,apache源码编译中首先安装pcre的原因
- 虚拟机:TTL 传输中过期
- 009 二维随机变量分布 min max 习题
- 火车头如何下载附件文件
- python开发积累