CF779B.Weird Rounding
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10_k_.
In the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10_k_. For example, if k = 3, in the number 30020 it is enough to delete a single digit (2). In this case, the result is 3000 that is divisible by 103 = 1000.
Write a program that prints the minimum number of digits to be deleted from the given integer number n, so that the result is divisible by 10_k_. The result should not start with the unnecessary leading zero (i.e., zero can start only the number 0, which is required to be written as exactly one digit).
It is guaranteed that the answer exists.
波利卡普对“整十数”情有独钟,尤其喜爱能被 10k 整除的数。
给定一个整数 n,波利卡普希望删去尽可能少的数字,使得剩余数字(按原顺序构成的新数)能被 10k 整除。例如,当 k=3 时,在数字 30020 中只需删去一位数字(即 2),即可得到 3000,而 3000 能被 103=1000 整除。
请编写一个程序,输出为使给定整数 n 经删去若干数字后能被 10k 整除所需删去的最少数字个数。结果不得包含多余的前导零(即:仅当结果为 0 时才可写作单个数字 0)。
题目保证答案一定存在。
输入格式
The only line of the input contains two integer numbers n and k (0 ≤ n ≤ 2 000 000 000, 1 ≤ k ≤ 9).
It is guaranteed that the answer exists. All numbers in the input are written in traditional notation of integers, that is, without any extra leading zeros.
输入仅包含一行,其中有两个整数 n 和 k(0 ≤ n ≤ 2 000 000 000,1 ≤ k ≤ 9)。
保证答案存在。输入中的所有数字均以整数的传统记法表示,即不含任何额外的前导零。
输出格式
Print w — the required minimal number of digits to erase. After removing the appropriate w digits from the number n, the result should have a value that is divisible by 10_k_. The result can start with digit 0 in the single case (the result is zero and written by exactly the only digit 0).
输出 w —— 需要删除的最少数字个数。从数字 n 中删除恰好 w 个数字后,所得结果的数值应能被 10k 整除。结果允许以数字 0 开头,但仅限一种情况:即结果为 0,且恰好由唯一一个数字 0 表示。
输入输出样例
输入#1
30020 3
输出#1
1
输入#2
100 9
输出#2
2
输入#3
10203049 2
输出#3
3
说明/提示
In the example 2 you can remove two digits: 1 and any 0. The result is number 0 which is divisible by any number.
在示例 2 中,你可以删除两个数字:1 和任意一个 0。结果得到数字 0,而 0 可被任何数整除。
输入解题思路,AI测评打分。不知道怎么写?