-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP1136.cpp
More file actions
66 lines (59 loc) · 1011 Bytes
/
Copy pathP1136.cpp
File metadata and controls
66 lines (59 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char s1[100],s2[100];
while(scanf("%s",&s1)!=EOF)
{
int m[202]={'\0'};
scanf("%s",&s2);
int a[200]={0},b[200]={0},l1,l2,c,k,i,j,flag;
l1=strlen(s1);
l2=strlen(s2);
if(l1==1||l2==1)
if(s1[0]=='0'||s2[0]=='0')
{cout<<0;
goto lable;}
if(l1<l2) k=l2;
else k=l1;c=k;
for(i=0;i<l1;k--,i++)
a[k]=s1[l1-1-i]-'0';
for(k=c,i=0;i<l2;k--,i++)
b[k]=s2[l2-1-i]-'0';
int t;
for(i=c;i>=0;i--)
for(j=c;j>=0;j--)
{
t=(c-i+1)+(c-j+1)-1;
m[t]=m[t]+(a[i]*b[j]);
}
m[t]=37;
for(i=1;m[i]!=37;i++)
{
if(m[i]>=10)
{
m[i+1]=m[i+1]+m[i]/10;
m[i]=m[i]%10;
}
}
m[i]=73;
i=1;
while(m[i]!=73)
{
i++;
}
flag=0;
while((i--)>1)
{
if(m[i]!=0)
flag=1;
if(flag)
cout<<m[i];
}
lable:
printf("\n");
}
return 0;
}