链接:

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. JS对字符串的操作,截取

    substring()  //一个参数的时候是从那个参数到字符串结束的位置: substring(start,stop)        //substring是对字符串两个索引之间的值进行截取: 要注 ...

  2. orcale备份语句

    1.创建一个文件夹,比如d盘下创建一个expdp的文件夹 d:\expdp2.使用一个用户,必须具有DBA权限 比如 sqlplus /nolog conn system/password@数据库连接 ...

  3. ES-实战

     一.环境准备 操作系统:mac 依赖的软件:JDK1.8.Postman.NodeJs6.0以上.Maven.Idea ES下载:Elastic官方网站: http://www.elastic.co ...

  4. 什么是云解析DNS?

    产品概述 云解析DNS(Alibaba Cloud DNS)是一种安全.快速.稳定.可扩展的权威DNS服务,云解析DNS为企业和开发者将易于管理识别的域名转换为计算机用于互连通信的数字IP地址,从而将 ...

  5. ARC081E. Don't Be a Subsequence

    $\newcommand{\dp}{\mathsf{dp}}$ $\newcommand{\next}{\mathsf{next}}$ Let $S$ be a string of lower cas ...

  6. MyBatis使用小结

  7. Kernel--试题

    1. 内核堆栈区别: 1.栈自动分配回收,函数里面声明的变量:2.堆:malloc kmalloc申请的空间,需要自己释放 https://blog.csdn.net/tainjau/article/ ...

  8. 图数据库-Neo4j-初探

    图数据库-Neo4j-初探 2018-08-17 本次初探主要学习如何安装Neo4j,以及Cypher的基本语法. 1. 安装Neo4j Desktop版本 neo4j-desktop Server版 ...

  9. Log4net采用外部配置文件和多记录器的方法

    1) 创建配置文件,可以放在任意位置,名字可以任意的xml文件 例如,文件名 Log.Config.xml,内容如下 <?xml version="1.0" encoding ...

  10. Sql语句知识大全

    1.经典SQL语句大全(绝对的经典) 2. 3. 4.一.基础 1.1.说明:创建数据库 2.CREATE DATABASE database-name 3.2.说明:删除数据库 4.drop dat ...