338 - Long Multiplication

All about problems in Volume 3. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

wyvmak
Experienced poster
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am

338 Long multiplication

Post 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?
Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Output

Post 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
wyvmak
Experienced poster
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am

Thanks

Post 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.
rmukadam
New poster
Posts: 4
Joined: Wed May 01, 2002 2:51 pm

Q338

Post 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????
ithamar
Learning poster
Posts: 56
Joined: Mon May 13, 2002 11:58 pm
Location: Venezuela

Post 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.)
10153EN
Experienced poster
Posts: 148
Joined: Sun Jan 06, 2002 2:00 am
Location: Hong Kong
Contact:

HI~~

Post 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?
AlexandreN
New poster
Posts: 27
Joined: Sun Jul 07, 2002 6:46 pm
Location: Campina Grande - Brazil
Contact:

Post by AlexandreN »

NO.
Mikalsen
New poster
Posts: 3
Joined: Sun Nov 03, 2002 8:24 pm
Location: Guimar
Contact:

338 - Long Multiplication

Post 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
Remi Mikalsen
Mikalsen
New poster
Posts: 3
Joined: Sun Nov 03, 2002 8:24 pm
Location: Guimar
Contact:

Excellent!

Post 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
.
Remi Mikalsen
Mikalsen
New poster
Posts: 3
Joined: Sun Nov 03, 2002 8:24 pm
Location: Guimar
Contact:

One last attempt!

Post 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
Remi Mikalsen
SoLtRiX
New poster
Posts: 10
Joined: Tue Dec 03, 2002 1:17 am
Location: Portugal
Contact:

338 - what's wrong whit this output??

Post 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
angga888
Experienced poster
Posts: 143
Joined: Sat Dec 21, 2002 11:41 am
Location: Indonesia

338 Long Multiplication

Post 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
Andrey Mokhov
Experienced poster
Posts: 128
Joined: Fri Nov 15, 2002 7:45 am
Location: Kyrgyzstan

Post 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:
angga888
Experienced poster
Posts: 143
Joined: Sat Dec 21, 2002 11:41 am
Location: Indonesia

Post 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:
Andrey Mokhov
Experienced poster
Posts: 128
Joined: Fri Nov 15, 2002 7:45 am
Location: Kyrgyzstan

Post 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!
Post Reply

Return to “Volume 3 (300-399)”