Custom Subtraction
A young girl named Emily is learning how to subtract one from a number, but she has a unique way of doing it when the number has two or more digits.
Emily follows these steps:
- If the last digit of the number is not zero, she simply subtracts one from the number.
- If the last digit of the number is zero, she divides the number by 10 (effectively removing the last digit).
You are given an integer number n. Emily will perform this subtraction process k times. Your task is to determine the final result after all k subtractions. It is guaranteed that the result will always be a positive integer.
Example 1
Input:
n = 512, k = 4
Output:
50
Explanation:
512â511â510â51â50
main.cpp
C++
AIã«è³ªåãã
AIã«è³ªåãã
äœã§ã質åããããææ¡ããã質åã®1ã€ã詊ããŠãã£ãããå§ããŠãã ãã