链接:

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. 关于spring 事务 和 AOP 管理事务和打印日志问题

    关于spring 事务 和 AOP 管理事务和打印日志问题 1. 就是支持事务注解的(@Transactional) . ​ 可以在server层总使用@Transactional,进行方法内的事务管 ...

  2. Comet OJ Contest #15 D. 双十一特惠(困难版)

    以 $d(x)$ 表示正整数 $x$ 的十进制表示的数位之和.熟知下列关于 $d(x)$ 的结论: $d(x) \equiv x \pmod{9}$.从而对于任意正整数列 $a_1, a_2, \do ...

  3. 【洛谷】P4202 [NOI2008]奥运物流

    [洛谷]P4202 [NOI2008]奥运物流 感觉有点降智 首先设环长为\(len\),很容易推导出 \[ R(1) = \frac{\sum_{i = 1}^{N} C_{i} k^{dep[i] ...

  4. 记搜狗一次不成功的Python后端面试经历

    面试搜狗Python后端结束快一个月了,终于有时间来做一个简单的总结了. 简介:工作不久,基础后端岗位,一面结束,失败. 先做了几个笔试题,面试开始会根据笔试题问一些内容.下面将整理一下还能想起来的内 ...

  5. jsp获取Session中的值

    摘要:这个问题算是老生常谈了,我也是一段时间没弄过了,所以感觉有些忘了,就记录一下. 一.后端通过shiro在session中存储数据: // username是前台传过来的用户名 if (subje ...

  6. .js文件中文乱码解决办法

    描述:.js文件里的中文内容在网页中显示乱码 解决办法:把JS文件的编码改为utf-8 VS2013解决步骤:文件——高级保存选项——Unicode (UTF-8带签名)  代码页 65001

  7. SIP协议入门:初学者必须明白的几个重要概念

    SIP协议初学者必须明白的几个重要概念 http://blog.sina.com.cn/s/blog_60e1d7bb0100f6er.html 一. SIP协议的分层结构 SIP是一个分层结构协议, ...

  8. JS的一些简单基础运算题

    1.输入一个四位数,在控制台分别显示个位,十位,百位,千位的数值 var a = prompt("请输入一个四位数的正整数"); var b = parseInt(a/1000); ...

  9. “最不合格”的SAP应聘者: 从大学生到SAP成都研究院开发工程师

    让我们把时光之轮倒拨回2006年,SAP成都研究院刚刚成立的时候,有一位年轻的电子科技大学研究生,网名雷米兰(这名字一看就是AC米兰铁杆粉丝),加入了SAP成都研究院并被派遣到SAP德国总部进行实习. ...

  10. Scala语言面向对象

    apply1. 面向对象的基本概念: 把数据及对数据的操作方法放在一起,作为一个相互依存的整体-----对象,面向对象的三大特征:封装.多态.继承 2. scala类的定义 · class Emplo ...