Page 1 of 4

338 Long multiplication

Posted: Thu Apr 25, 2002 8:50 am
by wyvmak
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?

Output

Posted: Thu Apr 25, 2002 7:16 pm
by Adrian Kuegel
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

Thanks

Posted: Fri Apr 26, 2002 3:58 am
by wyvmak
Thanks so so so much. I get Accepted, finally. I guess it could be a year or more since I first attempted this question. It looks that sometimes it's beyond my ability to solve a problem alone.

Q338

Posted: Fri May 17, 2002 5:30 am
by rmukadam
I wonder where am i going wrong for this que:

am printing blank spaces to the left and to the right of intermediate computations as required....

BUT :x am still getting Wrong answers....is there anything else i have to consider????

Posted: Fri May 17, 2002 4:56 pm
by ithamar
I dont believe that you get wrong answer because blank spaces, In my short experience i have noticed that when you send a correct program that gives correct output but with some blanks spaces that are not required you get: Acceped (P.E.)

HI~~

Posted: Fri May 17, 2002 5:09 pm
by 10153EN
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?

Posted: Tue Jul 23, 2002 4:24 pm
by AlexandreN
NO.

338 - Long Multiplication

Posted: Sun Nov 03, 2002 8:51 pm
by Mikalsen
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

Excellent!

Posted: Sun Nov 03, 2002 8:57 pm
by Mikalsen
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
.

One last attempt!

Posted: Sun Nov 03, 2002 9:03 pm
by Mikalsen
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

338 - what's wrong whit this output??

Posted: Tue Dec 03, 2002 1:19 am
by SoLtRiX
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

338 Long Multiplication

Posted: Thu Dec 26, 2002 1:45 pm
by angga888
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

Posted: Fri Dec 27, 2002 9:06 am
by Andrey Mokhov
My program got AC and it doesn't support negative numbers.
But it deletes leading zeroes.

What is your output for the input? I'll say if it is right or not. :wink:

Posted: Sat Dec 28, 2002 7:40 am
by angga888
*************
****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:
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:

Posted: Mon Dec 30, 2002 10:12 am
by Andrey Mokhov
Your output is correct. It's even better than mine - my program failed on the second case :oops: Maybe its too big numbers.

About zeroes - two zeroes are not the end of input - it's possibe data. Only one zero on line should be considered as delimiter.

Good luck!