Wrong Subtraction

简介: Wrong Subtraction

文章目录

一、Wrong Subtraction

总结


一、Wrong Subtraction

本题链接:Wrong Subtraction


题目:

A. Wrong Subtraction

time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard 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 n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions.


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


Input

The first line of the input contains two integer numbers n and k (2≤n≤109, 1≤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 n by one k times.


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


Examples


input

512 4

output

50


input

1000000000 9

output

1


Note

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


本博客给出本题截图:

image.png

题意:输入nk,把一个数按照如果各位是0就减1,否则除以10,求k次操作后得到的值为多少


AC代码

#include <iostream>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i ++ )
    if (n % 10) n --;
    else n /= 10;
  cout << n << endl;
  return 0;
}

总结

水题,不解释


目录
相关文章
|
4天前
|
人工智能 JavaScript 测试技术
Qwen3-Coder入门教程|10分钟搞定安装配置
Qwen3-Coder 挑战赛简介:无论你是编程小白还是办公达人,都能通过本教程快速上手 Qwen-Code CLI,利用 AI 轻松实现代码编写、文档处理等任务。内容涵盖 API 配置、CLI 安装及多种实用案例,助你提升效率,体验智能编码的乐趣。
328 102
|
4天前
|
JSON fastjson Java
FastJson 完全学习指南(初学者从零入门)
摘要:本文是FastJson的入门学习指南,主要内容包括: JSON基础:介绍JSON格式特点、键值对规则、数组和对象格式,以及嵌套结构的访问方式。FastJson是阿里巴巴开源的高性能JSON解析库,具有速度快、功能全、使用简单等优势,并介绍如何引入依赖,如何替换Springboot默认的JackJson。 核心API: 序列化:将Java对象转换为JSON字符串,演示对象、List和Map的序列化方法; 反序列化:将JSON字符串转回Java对象,展示基本对象转换方法;
|
5天前
|
缓存 JavaScript 前端开发
JavaScript 的三种引入方法详解
在网页开发中,JavaScript 可通过内联、内部脚本和外部脚本三种方式引入 HTML 文件,各具适用场景。本文详解其用法并附完整示例代码,帮助开发者根据项目需求选择合适的方式,提升代码维护性与开发效率。
197 110
|
5天前
|
Android开发 开发者 Windows
这是我设计的一种不关机,然后改造操作系统的软件设计思路2.0版本
本文介绍了在不重启系统的情况下实现操作系统改造的两种方案。第一种方案通过SLFM Recovery模式,在独立于操作系统的最高权限环境下完成系统更新与改造,并支持断电恢复与失败回滚。第二种方案采用多分区机制,通过SLFM套件在独立分区中完成系统改造,适用于可中断与不可中断服务场景,确保系统更新过程的安全与稳定。
230 132