algorithm Training Alpha producttime limit: 1.0s memory limit: 512.0MBThe problem description calculates the alpha product of an integer. For an integer x, its alpha product is calculated as this: if X is a single digit, then its alpha product is itself; otherwise, the Alpha product of x is equal to the alpha product of the integer that is obtained by multiplying the number of its members by 0. For example: The alpha product of 4018224312 equals 8, which is calculated by following these steps:
4018224312→4*1*8*2*2*4*3*1*2→3072→3*7*2→42→4*2→8
Write a program, enter a positive integer (the integer will not exceed 6,000,000), and output its alpha product.
Input format: Enter only one line, that is, a positive integer.
Output format: Outputs the corresponding alpha product.
Input and Output sample sample input 4018224312 sample output 8
ImportJava.util.Scanner; Public classMain {Static voidGetResult (Longnum) { LongN=1; Longi; //Export Design if(num<10) {System.out.println (num); return; } //Similar design Do{i=num%10; Num/=10; if(i!=0) {n*=i; } } while(num>0); //Recursive invocationGetResult (n); } Public Static voidMain (string[] args) {//TODO auto-generated Method StubScanner sc=NewScanner (system.in); Longnum=Sc.nextlong (); GetResult (num); }}
Algorithm Training Alpha Product