Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- string n;
- int c=0;
- int k;
- cin >> n >> k;
- vector<int>pos;
- for(int i=n.size()-1;i>=0;i--)
- {
- if(n[i]=='0')
- pos.push_back(i);
- }
- if(pos.size()>=k)
- {
- int temp = n.size()-1;
- for(int i=0;i<k;i++)
- {
- c+=temp-pos[i];
- temp=pos[i]-1;
- }
- cout << c << endl;
- return 0;
- }
- else cout << n.size()-1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement