链接:

https://codeforces.com/contest/1230/problem/B

题意:

Ania has a large integer S. Its decimal representation has length n and doesn't contain any leading zeroes. Ania is allowed to change at most k digits of S. She wants to do it in such a way that S still won't contain any leading zeroes and it'll be minimal possible. What integer will Ania finish with?

思路:

模拟构造即可.

代码:

#include <bits/stdc++.h>
using namespace std; const int MAXN = 2e5+10;
char s[MAXN];
int n, k; int main()
{
cin >> n >> k;
cin >> s;
int p = 0;
while (k > 0 && p < n)
{
if (p > 0 || p == n-1)
{
if (s[p] != '0')
{
s[p] = '0';
k--;
}
}
else
{
if (s[p] != '1')
{
s[p] = '1';
k--;
}
}
p++;
}
cout << s << endl; return 0;
}

Codeforces Round #588 (Div. 2) B. Ania and Minimizing(构造)的更多相关文章

  1. Codeforces Round #588 (Div. 2)-E. Kamil and Making a Stream-求树上同一直径上两两节点之间gcd的和

    Codeforces Round #588 (Div. 2)-E. Kamil and Making a Stream-求树上同一直径上两两节点之间gcd的和 [Problem Description ...

  2. Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)

    题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数 ...

  3. Codeforces Round #588 (Div. 2)

    传送门 A. Dawid and Bags of Candies 乱搞. Code #include <bits/stdc++.h> #define MP make_pair #defin ...

  4. Codeforces Round #588 (Div. 2) E. Kamil and Making a Stream(DFS)

    链接: https://codeforces.com/contest/1230/problem/E 题意: Kamil likes streaming the competitive programm ...

  5. Codeforces Round #588 (Div. 2) D. Marcin and Training Camp(思维)

    链接: https://codeforces.com/contest/1230/problem/D 题意: Marcin is a coach in his university. There are ...

  6. Codeforces Round #588 (Div. 2) C. Anadi and Domino(思维)

    链接: https://codeforces.com/contest/1230/problem/C 题意: Anadi has a set of dominoes. Every domino has ...

  7. Codeforces Round #588 (Div. 2) A. Dawid and Bags of Candies

    链接: https://codeforces.com/contest/1230/problem/A 题意: Dawid has four bags of candies. The i-th of th ...

  8. Codeforces Round #588 (Div. 1)

    Contest Page 因为一些特殊的原因所以更得不是很及时-- A sol 不难发现当某个人diss其他所有人的时候就一定要被删掉. 维护一下每个人会diss多少个人,当diss的人数等于剩余人数 ...

  9. Codeforces Round #588 (Div. 1) 简要题解

    1. 1229A Marcin and Training Camp 大意: 给定$n$个对$(a_i,b_i)$, 要求选出一个集合, 使得不存在一个元素好于集合中其他所有元素. 若$a_i$的二进制 ...

随机推荐

  1. poj2406(求字符串的周期,kmp算法next数组的应用)

    题目链接:https://vjudge.net/problem/POJ-2406 题意:求出给定字符串的周期,和poj1961类似. 思路:直接利用next数组的定义即可,当没有周期时,周期即为1. ...

  2. 【Python】【demo实验36】【基础实验】【求3*3矩阵的主对角线之和】

    题目: 求一个3*3矩阵主对角线元素之和. 主对角线:从左上多右下的书归为主对角线 副对角线:从左下至右上的数归为副对角线. 我的源码: #!/usr/bin/python # encoding=ut ...

  3. appium+python教程1

    Python3+Appium安装使用教程 一.安装 我们知道selenium是桌面浏览器自动化操作工具(Web Browser Automation) appium是继承selenium自动化思想旨在 ...

  4. (十)springMvc 校验

    目录 文章目录 目录 @[toc] springMvc 校验 准备 踩坑 配置校验器 将校验器注入到适配器中 在 pojo 中配置校验规则 在 controller 层进行检验 获取错误信息 将错误信 ...

  5. 散列查找的C实现

    概念 散列查找,类似与查英文字典的过程.如果我们要查找"zoo"(key)对应的释义(value),我们不会从第一页开始逐页查找(顺序查找),而是直接根据大致的推算(Hash函数) ...

  6. Ubuntu 提示sudo: java: command not found解决办法

    ubuntu下运行sudo Java 时提示“sudo: java: command not found”.在网上找了,其中很多方法都提示要修改/etc/profile的配置,或是修改/etc/env ...

  7. github骚操作

    限制搜索 in关键词限制搜索范围 命令 说明 xxx in:name 项目名包含xxx的 xxx in:description 项目描述包含xxx的 xxx in:readme 项目的readme文件 ...

  8. QT开发小技巧-窗口处理(一)

    this->setWindowFlags(Qt::WindowCloseButtonHint); // 仅保留关闭按钮 this->setAttribute(Qt::WA_DeleteOn ...

  9. 使用Seaborn展示多变量两两之间的关系

    数据展示: 1. FacetGrid FacetGrid是一个储存我们想怎样展示信息的东西,如下所示,我们想观察位置中SK和GK的分布. 在这里我们使用map方法把数据填充到图表中 计算类别在某一特征 ...

  10. 重拾MVC——第二天:Vue学习与即时密码格式验证

    今天是复习MVC的第二天,准备自己写一个后台管理,然后慢慢写大,做全. 个人感觉做 Web 的,前端知识是必备的,所有今天学习了一下 Vue,很多人用这个,我以前没有用过,今天把它补起来. 比较了各个 ...