338 - Long Multiplication
Moderator: Board moderators
338 Long multiplication
I got frustrated with this Q, i think i've got (at least) several tens of WA on this single problem already.
Would someone tell me what's the output for:
1100 1100
1020 1020
2520 2000
1245 9
9 12345
0
What are other tricky cases?
Or any output description not matching the description in the problem?
Would someone tell me what's the output for:
1100 1100
1020 1020
2520 2000
1245 9
9 12345
0
What are other tricky cases?
Or any output description not matching the description in the problem?
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
Output
A single space is not displayed, but it should be there.
Code: Select all
1100
1100
----
1100
1100
-------
1210000
1020
1020
----
2040
1020
-------
1040400
2520
2000
----
5040000
1245
9
----
11205
9
12345
-----
45
36
27
18
9
------
111105
HI~~
However for this kind of problems, which require us to print the numbers with a specific format (e.g. in this problem, in the format of a multiplication step) will the indentation or space printing take effect for your W.A?
-
- New poster
- Posts: 27
- Joined: Sun Jul 07, 2002 6:46 pm
- Location: Campina Grande - Brazil
- Contact:
338 - Long Multiplication
I am always getting wrong answer on this one. I wonder if anyone can give me tips on correct input-output. I will give some examples of output generated from certain input by my "non-working" solution. If, on one hand, anyone spots errors in the output, or, on the other hand, anyone has in mind some special cases that could lead to erroneous output, please tell me!
(Attention to the number of '-'!)
Input:
9999999999 9999999999
0 100
200 200
202 202
0
Output:
9999999999
9999999999
----------
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
--------------------
99999999980000000001
0
100
---
0
200
200
----
40000
202
202
---
404
404
-----
40804
(Attention to the number of '-'!)
Input:
9999999999 9999999999
0 100
200 200
202 202
0
Output:
9999999999
9999999999
----------
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
89999999991
--------------------
99999999980000000001
0
100
---
0
200
200
----
40000
202
202
---
404
404
-----
40804
Remi Mikalsen
Excellent!
It seems that this forum erases the blanks in the beginning of the line, meaning that the output format is completely wrong. I'll try again, this time I'll put a character in the beginning of each line, praying that repeating blanks is ok in the middle of a sentence! I'm sorry about the mess!
Input:
9999999999 9999999999
0 100
200 200
202 202
0
Output:
.
. 9999999999
. 9999999999
. ----------
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. --------------------
.99999999980000000001
.
. 0
.100
. ---
. 0
.
. 200
. 200
. ----
.40000
.
. 202
. 202
. ---
. 404
.404
. -----
.40804
.
Input:
9999999999 9999999999
0 100
200 200
202 202
0
Output:
.
. 9999999999
. 9999999999
. ----------
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. 89999999991
. --------------------
.99999999980000000001
.
. 0
.100
. ---
. 0
.
. 200
. 200
. ----
.40000
.
. 202
. 202
. ---
. 404
.404
. -----
.40804
.
Remi Mikalsen
One last attempt!
Ok... this is a last attempt! I'll replace the blanks with X.
Input:
9999999999 9999999999
0 100
200 200
202 202
0
Output:
XXXXXXXXXX9999999999
XXXXXXXXXX9999999999
XXXXXXXXXXXX----------
XXXXXXXXX89999999991
XXXXXXXX89999999991
XXXXXXX89999999991
XXXXXX89999999991
XXXXX89999999991
XXXX89999999991
XXX89999999991
XX89999999991
X89999999991
89999999991
--------------------
99999999980000000001
XX0
100
X---
XX0
XX200
XX200
XX----
40000
XX202
XX202
XXX---
XX404
404
X-----
40804
Input:
9999999999 9999999999
0 100
200 200
202 202
0
Output:
XXXXXXXXXX9999999999
XXXXXXXXXX9999999999
XXXXXXXXXXXX----------
XXXXXXXXX89999999991
XXXXXXXX89999999991
XXXXXXX89999999991
XXXXXX89999999991
XXXXX89999999991
XXXX89999999991
XXX89999999991
XX89999999991
X89999999991
89999999991
--------------------
99999999980000000001
XX0
100
X---
XX0
XX200
XX200
XX----
40000
XX202
XX202
XXX---
XX404
404
X-----
40804
Remi Mikalsen
338 - what's wrong whit this output??
12345
862
-----
24690
74070
98760
--------
10641390
100003
100010
------
100003
100003
-----------
10001300030
345
3455
----
1725
1725
1380
1035
-------
1191975
0
123456789
---------
0
2
324
---
8
4
6
---
648
0
234
---
0
862
-----
24690
74070
98760
--------
10641390
100003
100010
------
100003
100003
-----------
10001300030
345
3455
----
1725
1725
1380
1035
-------
1191975
0
123456789
---------
0
2
324
---
8
4
6
---
648
0
234
---
0
338 Long Multiplication
Please answer my question below :
Can the input be negative integer?
What should be the output if the input can be negative integer (e.g: -546)?
Can it be sequence of zero before the number (e.g: 00034 00005)
And please give me the output of these inputs :
1000 -13
0000000000000000000001322011310000 00009878756000
0 100
1 0
2520 2000
1100 1100
0 234
0 123456789
345 3455
100003 100010
5464564569 0001234567899
01010 1003
879879789 0
0
And also is there any strange and special input?
Regards,
Angga888
Can the input be negative integer?
What should be the output if the input can be negative integer (e.g: -546)?
Can it be sequence of zero before the number (e.g: 00034 00005)
And please give me the output of these inputs :
1000 -13
0000000000000000000001322011310000 00009878756000
0 100
1 0
2520 2000
1100 1100
0 234
0 123456789
345 3455
100003 100010
5464564569 0001234567899
01010 1003
879879789 0
0
And also is there any strange and special input?
Regards,
Angga888
-
- Experienced poster
- Posts: 128
- Joined: Fri Nov 15, 2002 7:45 am
- Location: Kyrgyzstan
*************
****INPUT****
*************
1000 -13
0000000000000000000001322011310000 00009878756000
0 100
1 0
2520 2000
1100 1100
0 234
0 123456789
345 3455
100003 100010
5464564569 0001234567899
01010 1003
879879789 0
0 0
0
**************
****OUTPUT****
**************
.1000
...13
.----
.3000
1000
-----
13000
..........1322011310000
.............9878756000
..........-------------
.......7932067860000
......6610056550000
.....9254079170000
...10576090480000
...9254079170000
.10576090480000
11898101790000
-----------------------
13059827160730360000000
..0
100
---
..0
1
0
-
0
...2520
...2000
...----
5040000
...1100
...1100
...----
.1100
1100
-------
1210000
..0
234
---
..0
........0
123456789
---------
........0
....345
...3455
...----
...1725
..1725
.1380
1035
-------
1191975
.....100003
.....100010
.....------
....100003
100003
-----------
10001300030
.........5464564569
.........1234567899
.........----------
........49181081121
.......49181081121
......43716516552
.....38251951983
....32787387414
...27322822845
..21858258276
.16393693707
10929129138
5464564569
-------------------
6746375998900170531
...1010
...1003
...----
...3030
1010
-------
1013030
879879789
........0
---------
........0
0
0
-
0
( . shows the space )
I added one more input ( 0 0 ) at the end, should that kind of input be calculated ?
Please check my output and tell me the mistakes.
What kind of zero indicates the end of file ?
(e.g. 0 or 00 or 00..0 or ...0 or etc)( . shows the space).
Regards,
Angga888![:lol:](./images/smilies/icon_lol.gif)
****INPUT****
*************
1000 -13
0000000000000000000001322011310000 00009878756000
0 100
1 0
2520 2000
1100 1100
0 234
0 123456789
345 3455
100003 100010
5464564569 0001234567899
01010 1003
879879789 0
0 0
0
**************
****OUTPUT****
**************
.1000
...13
.----
.3000
1000
-----
13000
..........1322011310000
.............9878756000
..........-------------
.......7932067860000
......6610056550000
.....9254079170000
...10576090480000
...9254079170000
.10576090480000
11898101790000
-----------------------
13059827160730360000000
..0
100
---
..0
1
0
-
0
...2520
...2000
...----
5040000
...1100
...1100
...----
.1100
1100
-------
1210000
..0
234
---
..0
........0
123456789
---------
........0
....345
...3455
...----
...1725
..1725
.1380
1035
-------
1191975
.....100003
.....100010
.....------
....100003
100003
-----------
10001300030
.........5464564569
.........1234567899
.........----------
........49181081121
.......49181081121
......43716516552
.....38251951983
....32787387414
...27322822845
..21858258276
.16393693707
10929129138
5464564569
-------------------
6746375998900170531
...1010
...1003
...----
...3030
1010
-------
1013030
879879789
........0
---------
........0
0
0
-
0
( . shows the space )
I added one more input ( 0 0 ) at the end, should that kind of input be calculated ?
Please check my output and tell me the mistakes.
![:wink:](./images/smilies/icon_wink.gif)
What kind of zero indicates the end of file ?
(e.g. 0 or 00 or 00..0 or ...0 or etc)( . shows the space).
Regards,
Angga888
![:lol:](./images/smilies/icon_lol.gif)
-
- Experienced poster
- Posts: 128
- Joined: Fri Nov 15, 2002 7:45 am
- Location: Kyrgyzstan