Algorithm Training Alpha Product

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.