标签:digits zeroes SS leading Codeforces 588 Ania include define
Ania has a large integer SS. Its decimal representation has length nn and doesn't contain any leading zeroes. Ania is allowed to change at most kk digits of SS. She wants to do it in such a way that SS still won't contain any leading zeroes and it'll be minimal possible. What integer will Ania finish with?
InputThe first line contains two integers nn and kk (1≤n≤2000001≤n≤200000, 0≤k≤n0≤k≤n) — the number of digits in the decimal representation of SSand the maximum allowed number of changed digits.
The second line contains the integer SS. It's guaranteed that SS has exactly nn digits and doesn't contain any leading zeroes.
OutputOutput the minimal possible value of SS which Ania can end with. Note that the resulting integer should also have nn digits.
Examples input Copy5 3 51528output Copy
10028input Copy
3 2 102output Copy
100input Copy
1 1 1output Copy
0Note
A number has leading zeroes if it consists of at least two digits and its first digit is 00. For example, numbers 0000, 0006900069 and 01010101 have leading zeroes, while 00, 30003000 and 10101010 don't have leading zeroes.
#include <iostream> #include <algorithm> #include <cstdio> #include <string> #include <cstring> #include <cstdlib> #include <map> #include <vector> #include <set> #include <queue> #include <stack> #include <cmath> using namespace std; #define ull unsigned long long #define lli long long #define pq priority_queue<int> #define pql priority_queue<ll> #define pqn priority_queue<node> #define v vector<int> #define vl vector<ll> #define read(x) scanf("%d",&x) #define lread(x) scanf("%lld",&x); #define pt(x) printf("%d\n",(x)) #define YES printf("YES\n"); #define NO printf("NO\n"); #define gcd __gcd #define out(x) cout<<x<<endl; #define over cout<<endl; #define rep(j,k) for (int i = (int)(j); i <= (int)(k); i++) #define input(k) for (int i = 1; i <= (int)(k); i++) {scanf("%d",&a[i]) ; } #define mem(s,t) memset(s,t,sizeof(s)) #define ok return 0; #define TLE std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define mod(x) ((x)%9973) #define test cout<<" ++++++ "<<endl; //二叉树 #define lson rt<<1, l, m #define rson rt<<1|1, m+1, r //线段树 #define ls now<<1 #define rs now<<1|1 //int dir[6][3] = {0,0,1,0,0,-1,1,0,0,-1,0,0,0,1,0,0,-1,0}; //int dir[4][2] = {1,0,-1,0,0,1,0,-1}; //单位移动 //int dir[8][2] = {2,1,2,-1,-2,1,-2,-1,1,2,1,-2,-1,2,-1,-2}; int t,n,m,k,x,y,col,ex,ey,ans,cnt,ly; string str; int a[5];; int main() { while(cin>>n>>k) { cin>>str; if(!k) cout<<str<<endl; else if(n==1) cout<<0<<endl; else { if(str[0]!='1') {str[0] = '1';k--;} for(int i=1; i<str.size() && k; i++) { if(str[i]!='0') {str[i]='0';k--;} } cout<<str<<endl; } } }
标签:digits,zeroes,SS,leading,Codeforces,588,Ania,include,define 来源: https://www.cnblogs.com/Shallow-dream/p/11577734.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。