← 返回 capitalone 的题目列表Subtract Product and Sum of Digits of a Large Number
类型:online_judge
Problem
Given a non-negative integer num, which may be very large and is therefore provided as a string, split it into decimal digits and compute:
product: the product of all digits
sum: the sum of all digits
Return product - sum.
Input Format
One line containing a string num consisting only of digit characters '0' to '9'.
Output Format
Print one integer: the difference between the product and the sum of all digits, i.e. product - sum.
Constraints
1 <= len(num) <= 10^4
num contains only digit characters
Leading zeros are allowed
Output the exact integer, without modulo
Example
Input:
234
Output:
15
Explanation: the product is 2 * 3 * 4 = 24, the sum is 2 + 3 + 4 = 9, so the answer is 24 - 9 = 15.
Example
Input
234
Output
15