UVA 10106 Product High precision operation

Source: Internet
Author: User

J-Product crawling in process ... crawling failedTime limit:MS Memory Limit:0KB 64bit IO Format:%lld &%llu SubmitStatus

Description


Product

The problem

The problem is to multiply, integers X, Y. (0<=x,y<10250)

The Input

The input would consist of a set of pairs of lines. Each line in pair contains one multiplyer.

The Output

For each input pair of lines the output line should consist one integer the product.

Sample Input

12122222222222222222222222222

Sample Output

144444444444444444444444444

Virtual judge not to be able to turn on UVA not to be helpless with a mobile phone to open the heart tired of VPN

Accode:

    #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #def    INE MAXN 10000 using namespace std;    Char A[MAXN],B[MAXN];    int ans[maxn*2];        int main () {int lena,lenb;            while (scanf ("%s", a)!=eof) {scanf ("%s", b); if (!strcmp (A, "0") | |!                strcmp (b, "0")) {printf ("0\n");            Continue            } memset (ans,0,sizeof (ans));            Lena=strlen (a);            Lenb=strlen (b);            Ans[0]=lena+lenb;            int t1,t2;                    for (int i=lena;i>0;--i) {for (int j=lenb;j>0;--j) {t1=a[i-1]-' 0 ';                    t2=b[j-1]-' 0 ';                Ans[i+j]+=t1*t2; }} for (int i=ans[0];i>0;--i) {if (ans[i]>10) {ans[i-1]+=ans[                    I]/10;                ans[i]%=10;            }} int t=1; while (ans[t]==0) t++;            for (int i=t;i<=ans[0];++i) cout<<ans[i];        Putchar (' \ n ');    } return 0; }


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

UVA 10106 Product High precision operation

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.