C++程序,用于删除数字字符串中的字符,使其能被8整除
Given a number in the form of a string, we need to find where to make it divisible by eight after deleting zero or more elements. In other words, we need to find whether there is a subsequence of the string, which is divisible by 8. Return the modified string or -1 if it is not possible.
根据可整除规则,任何最后三位数字可被8整除的数也可被8整除。例如,56992992和476360可被8整除,但2587788不能。如果结果是一个整数,则原始数可被8整除。
Let us look at some input scenarios that explain the method in detail −
如果传递给该方法的输入是包含任何可被8整除的子字符串的数字字符串,则在结果列表中我们可以获得可被8整除的子字符串−
Input: 2567992 Result: 56 登录后复制