#C11326. Product of Digits

    ID: 40630 Type: Default 1000ms 256MiB

Product of Digits

Product of Digits

You are given several lines of input, each line containing a string that represents a large non-negative integer. The input terminates when a line containing a single asterisk (*) is encountered. For each number read before the termination symbol, compute the product of its digits.

For example, if the input is:

123
45
678
*

Then the output should be:

6 20 336

Note: The product is defined as \(\prod_{i=1}^{n} d_i\) where each \(d_i\) is a digit of the number. In \(\LaTeX\) format, if \(N\) is represented as \(d_1d_2\cdots d_n\), then the product is given by:

[ P(N)=\prod_{i=1}^{n} d_i ]

Please ensure that your solution can handle very large numbers. You can assume that the number of digits in an input number can be up to 1000.

inputFormat

The input is read from the standard input (stdin) and consists of several lines:

  • Each line contains a non-empty string representing a large non-negative integer.
  • The input terminates with a line that contains a single asterisk (*). This sentinel is not processed.

There will be at least one number before the termination symbol.

outputFormat

Output a single line to the standard output (stdout) containing the products of the digits of each number (in the order they were read), separated by a space.

## sample
123
*
6