#K1786. Maximum Unique Subsequence Sum
Maximum Unique Subsequence Sum
Maximum Unique Subsequence Sum
Given a string representation of a positive integer N, your task is to compute the sum of its unique digits. In other words, extract each digit from N (ignoring repetitions) and output the sum of these distinct digits. The problem can be formally described as follows:
Let \(N\) be a positive integer represented as a string. Consider the set of digits contained in \(N\). The answer is defined as:
\(\text{Answer} = \sum_{d \in \text{unique digits of }N} d\)
For example, if N = "987654321", the unique digits are {9,8,7,6,5,4,3,2,1} and their sum is 45. Similarly, for N = "123123", the unique digits are {1,2,3} and their sum is 6.
Note: The input may contain leading zeros, and the digit '0' should be counted only once if present. Write a complete program that reads the input from standard input and outputs the result to standard output.
inputFormat
The input consists of a single line containing the string N representing a positive integer.
Example:
123123
outputFormat
Output a single integer which is the sum of the unique digits found in N.
Example:
6## sample
987654321
45