time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Input

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

Output

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.

Examples
input

Copy
  1. 512 4
output

Copy
  1. 50
input

Copy
  1. 1000000000 9
output

Copy
  1. 1
Note

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

  1. #include<iostream>
  2. #include<string.h>
  3. using namespace std;
  4. int main()
  5. {
  6. int k;
  7. char a[];
  8. while(cin>>a>>k)
  9. {
  10. int len=strlen(a);
  11. int j=;
  12. for(int i=;i<k;i++)
  13. {
  14. if(a[len--j]=='')
  15. {
  16. a[len--j]='*';
  17. j++;
  18. }
  19. else
  20. a[len--j]=a[len--j]-;
  21. }
  22.  
  23. for(int i=;i<len;i++)
  24. {
  25. if(a[i]!='*')
  26. cout<<a[i];
  27. }
  28. cout<<endl;
  29.  
  30. }
  31. return ;
  32. }

A. Wrong Subtraction的更多相关文章

  1. PAT 解题报告 1050. String Subtraction (20)

    1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...

  2. [leetcode-592-Fraction Addition and Subtraction]

    Given a string representing an expression of fraction addition and subtraction, you need to return t ...

  3. [LeetCode] Fraction Addition and Subtraction 分数加减法

    Given a string representing an expression of fraction addition and subtraction, you need to return t ...

  4. 【CF932E】Perpetual Subtraction(NTT,线性代数)

    [CF932E]Perpetual Subtraction(NTT,线性代数) 题面 洛谷 CF 题解 设\(f_{i,j}\)表示\(i\)轮之后这个数恰好为\(j\)的概率. 得到转移:\(\di ...

  5. [Swift]LeetCode592. 分数加减运算 | Fraction Addition and Subtraction

    Given a string representing an expression of fraction addition and subtraction, you need to return t ...

  6. PAT 1050 String Subtraction

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  7. [OpenCV] Samples 15: Background Subtraction and Gaussian mixture models

    不错的草稿.但进一步处理是必然的,也是难点所在. Extended: 固定摄像头,采用Gaussian mixture models对背景建模. OpenCV 中实现了两个版本的高斯混合背景/前景分割 ...

  8. 1050 String Subtraction (20 分)

    1050 String Subtraction (20 分) Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the ...

  9. 为什么委托的减法(- 或 -=)可能出现非预期的结果?(Delegate Subtraction Has Unpredictable Result)

    当我们为一个委托写 -= 的时候,ReSharper 会提示“Delegate Subtraction Has Unpredictable Result”,即“委托的减法可能出现非预期的结果”.然而在 ...

  10. Codeforces Round #525 (Div. 2)B. Ehab and subtraction

    B. Ehab and subtraction 题目链接:https://codeforc.es/contest/1088/problem/B 题意: 给出n个数,给出k次操作,然后每次操作把所有数减 ...

随机推荐

  1. oracle --(三)数据段(segment)

    基本关系:数据库---表空间---数据段---分区---数据块 数据段(segment)段(segment)由一系列的extent组成.通常一张表是一个segment. Oracle中的段可以分成4种 ...

  2. 修改Win10默认窗口背景色为护眼色的方法

    按Windows键+R,打开“运行”对话框,输入regedit: 修改[HKEY_CURRENT_USER\Control Panel\Colors]下Windows键值为 199 237 204, ...

  3. Codeforces #505(div1+div2) C Plasticine zebra

    题意:给你一段字符串,可以选择任意多的位置,每个位置会反转两边的字符串,问交错的字符串最长是多长? 思路:找规律,仔细分析样例1.假设位置为 1 2 3 4 5 6 7 8 9,反转之后会发现答案是7 ...

  4. windows平台下用C#访问HBase

    Hadoop中的HBase有多种数据访问方式,ubuntu里可以用hbase shell查看操作hbase数据库,但windows平台下需要用thrift对它进行访问. 例如hadoop安装在/usr ...

  5. java全栈day09----继承 抽象类

    01继承的概述 在Java中,类的继承是指在一个现有类的基础上去构建一个新的类, 构建出来的新类被称作子类,现有类被称作父类在java中 继承如何来实用呢?举个例子 继承的定义格式和使用 *A:继承的 ...

  6. Xshell连接linux(deepin)时提示ssh服务器拒绝了密码,请再试一次解决方法

    用Xshell root连接时显示ssh服务器拒绝了密码,应该是应该是sshd的设置不允许root用户用密码远程登录 修改 /etc/ssh/sshd_config文件,注意,安装了openssh才会 ...

  7. 国内物联网平台(5):机智云IoT物联网云服务平台及智能硬件自助开发平台

    国内物联网平台(5)——机智云IoT物联网云服务平台及智能硬件自助开发平台 马智 平台定位 机智云平台是致力于物联网.智能硬件云服务的开放平台.平台提供了从定义产品.设备端开发调试.应用开发.产测.运 ...

  8. linux定制的补充

    上一篇博文:http://www.cnblogs.com/hjc4025/p/6918323.html 这篇文章是对之前博文的一点扩展和补充: 这里主要是在之前的基础上添加了一些自己制作好的程序,还有 ...

  9. Info.plist文件配置及注意事项

    1.Info.plist文件配置 常见配置 2.注意事项 Info.plist文件移动路径修改编译报错:could not read data from '/Users/lelight/Desktop ...

  10. C语言和sh脚本的杂交代码

    在网上看到了一个把 C语言和bash杂并起来的例子,这个示子如下所示.在下面这个例子中,我们把脚本用#if 0这个预编译给起来,这样就不会让其编译到C语言中了. #if 0 echo "He ...