J-Product
crawling in process ...
crawling failedTime
limit:MS
Memory Limit:0KB
64bit IO Format:%lld &%llu SubmitStatus
Description
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