CF977A.Wrong Subtraction

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm:

  • if the last digit of the number is non-zero, she decreases the number by one;
  • if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit).

You are given an integer number nn. Tanya will subtract one from it kk times. Your task is to print the result after all kk subtractions.

It is guaranteed that the result will be positive integer number.

小女孩塔尼娅正在学习如何将一个数减一,但当这个数包含两位或更多位数字时,她会错误地执行减一操作。塔尼娅按照以下算法对一个数减一:

  • 如果该数的最后一位数字非零,则她将该数减一;
  • 如果该数的最后一位数字为零,则她将该数除以 1010(即去掉最后一位数字)。

给定一个整数 nn。塔尼娅将对该数连续执行 kk 次减一操作。你的任务是输出经过全部 kk 次减一操作后的结果。

保证最终结果为正整数。

输入格式

The first line of the input contains two integer numbers nn and kk (2≤n≤1092 \le n \le 10^9, 1≤k≤501 \le k \le 50) — the number from which Tanya will subtract and the number of subtractions correspondingly.

输入的第一行包含两个整数 nn 和 kk(2≤n≤1092 \le n \le 10^9,1≤k≤501 \le k \le 50),分别表示塔尼娅将从中减去的数以及减法操作的次数。

输出格式

Print one integer number — the result of the decreasing nn by one kk times.

It is guaranteed that the result will be positive integer number.

输出一个整数——将 nn 重复减 11 共 kk 次后的结果。

保证结果为正整数。

输入输出样例

  • 输入#1

    512 4

    输出#1

    50
  • 输入#2

    1000000000 9

    输出#2

    1

说明/提示

The first example corresponds to the following sequence: 512→511→510→51→50512 \rightarrow 511 \rightarrow 510 \rightarrow 51 \rightarrow 50.

第一个示例对应以下序列:512→511→510→51→50512 \rightarrow 511 \rightarrow 510 \rightarrow 51 \rightarrow 50。

输入解题思路,AI测评打分。不知道怎么写?

首页