The 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
1#include <iostream>2#include <string>3 using namespacestd;4 intMain ()5 {6 stringA;7 intb[Ten];8 Long Longsum=1;9 Long LongC;Ten intK; One intLen; A intJ; -Cin>>A; -len=a.length (); the for(intI=a.length ()-1; i>=0; i--) - { -b[i]=a[i]-'0'; - //cout<<b[i]; + } - //cout<<endl; + while(len!=1) A { at for(j=0; j<len;j++) - { - if(b[j]!=0) -sum=sum*B[j]; - } - //cout<< "sum" <<sum<<endl; inC=sum; -sum=1; tok=0; + while(c) - { the *b[k]=c%Ten; $c=c/Ten;Panax Notoginsengk++; -len=K; the } + //cout<< "Len" <<len<<endl; A the } +cout<<b[0];//<<b[1]<<b[2]; - return 0; $}
Algorithm Training Alpha Product