B. Weird rounding time limit per test 1 second memory limit per test megabytes input standard input Output standard OU Tput
Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10k.
In the given number of N Polycarp wants to remove the least number of digits to get a number which is divisible by 10k. For example, if k = 3, in the number 30020 it was enough to delete a and a single digit (2). The result is an divisible by 103 = 1000.
Write A program This prints the minimum number of digits to is deleted from the given integer number n, so that the result is divisible by10k. The result should not start with the unnecessary leading zero (i.e., zero can start only the number 0, which is required t o be written as exactly one digit).
It's guaranteed that the answer exists. Input
The only line of the input contains the integer numbers n and K (0≤n≤2 000 000 000, 1≤k≤9).
It's guaranteed that the answer exists. All numbers in the input was written in traditional notation of integers, that's, without any extra leading zeros. Output
Print w-the required minimal number of digits to erase. After removing the appropriate w digits from the number n, the result should has a value of that was divisible by 10k. The result can start with a digit 0 in the single case (the result was zero and written by exactly the only digit 0). Examples input
30020 3
Output
1
Input
100 9
Output
2
Input
10203049 2
Output
3
Note
In the example 2 you can remove both digits:1 and any 0. The result is a number 0 which is divisible by any number.
Simulation can be. Note: 0 is divisible by any number
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#define N 200020
using namespace std;
Char Ch[n];
int K,ans;
int main ()
{
scanf ("%s%d", ch+1,&k);
int Len=strlen (ch+1);
int now,cnt=0,num=0;
for (int i=1;i<=len;i++)
{
if (ch[i]== ' 0 ')
num++;
}
if (num==1&&len==1)
{
printf ("0\n");
return 0;
}
else if (num<k&&num)
{
printf ("%d\n", len-1);
return 0;
}
for (now=len;now;now--)
{
if (ch[now]== ' 0 ') cnt++;
else ans++;
if (cnt>=k) break;
} printf ("%d\n", ans);
return 0;
}