-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3117.cpp
More file actions
74 lines (63 loc) · 1.47 KB
/
3117.cpp
File metadata and controls
74 lines (63 loc) · 1.47 KB
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
67
68
69
70
71
72
73
74
/*************************************************************************
> File Name: 3117.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年03月02日 星期三 15时28分58秒
************************************************************************/
#include<iostream>
#include<cstring>
#include<stdio.h>
using namespace std;
char a[600];
char b[600];
char c[6000];
int main()
{
char t[600];
int f1 = 0, f2 = 0;
memset(t, 0, sizeof(t));
cin>>t;
if(t[0] == '-') f1 = 1;
int len_t = strlen(t);
for(int i = 0; i < len_t - f1; i++)
{
a[i] = t[len_t - i - 1] - '0';
}
memset(t, 0, sizeof(t));
cin>>t;
if(t[0] == '-') f2 = 1;
len_t = strlen(t);
for(int i = 0; i < len_t - f2; i++)
{
b[i] = t[len_t - i - 1 ] - '0';
}
int flag = f1 * f2;
/*
cout<<a<<endl;
cout<<b<<endl;
cout<<flag<<endl;
*/
for(int i = 0; i < 600; i++)
{
for(int j = 0; j < 600; j++)
{
c[i+j] += a[i] * b[j]; //注意细节,这里是加等,不是等
if(c[i+j] >= 10 )
{
// printf("jinwei: %d\n", c[i+j] / 10);
c[i+j+1] += c[i+j] / 10;
c[i+j] %= 10;
}
}
}
if( f1 ^ f2 ) printf("-");
int i;
for( i = 0; i < 2000; i++)
{
if(c[2000 - i] != 0) break;
}
while(2000 - i >= 0){
printf("%d", c[2000 - i]);
i++;
}
}