Problem Statement
Scientists recently received the following transmission from outer space: "000023 * 000011 = 002093". While many rejoiced at this sure sign of intelligent alien life, others pointed out that any such alien life could not be too intelligent since 23 * 11 actually equals 253, not 2093. Not to be put off, the scientists noticed that the equation could easily be corrected by changing the second to last digit in 000011 to a 9. Based on this, they have hypothesized that the message was initially correct, but that it was corrupted during its lengthy transmission to Earth.
Numerous other messages have been received since then, always of the form "a * b = c", where a, b, c are six digit numbers (possibly including leading zeros). Scientists believe the aliens are ignoring overflow, so that c is only intended to represent the last six digits of a * b. Given this, most of the messages have been correct, but a few do have mistakes, and the scientists wonder how well these mistakes can be explained by data corruption. To answer this, they want you to create a class AlienMultiplication that contains the method getCorrections, which takes an
Definition
- Class:
- AlienMultiplication
- Method:
- getCorrections
- Parameters:
- int, int, int
- Returns:
- int
- Method signature:
- int getCorrections(int a, int b, int c)
- (be sure your method is public)
Notes
- a, b and c should always be interpreted as having precisely six digits, possibly including leading zeros. Thus, there are always a total of eighteen digits that may be changed, six in each of a, b, and c.
Constraints
- a, b, and c will each be between 0 and 999,999 inclusive.
Examples
23
11
2093
Returns: 1
This is the example from the problem statement.
1538
951234
997892
Returns: 0
Since c is only required to equal the last six digits of a * b, this equation is already correct.
153
7
71
Returns: 1
Since c is always interpreted as a six digit number, this equation can be corrected by changing c from 000071 to 001071.
421368
512357
862812
Returns: 4
This can be corrected by changing b to 512312 and c to 882816.
0
0
987654
Returns: 5
0
0
999979
Returns: 6
563585
193304
234840
Returns: 0
456099
271879
301579
Returns: 4
650507
531387
264116
Returns: 3
941068
286087
733440
Returns: 1
716418
902697
38575
Returns: 5
188275
247688
146200
Returns: 1
420674
801738
909909
Returns: 5
197621
852842
872837
Returns: 4
72580
651966
328178
Returns: 2
899014
206488
37268
Returns: 4
267403
291970
653910
Returns: 0
292854
870082
813164
Returns: 4
176013
14465
715323
Returns: 5
113425
297921
396425
Returns: 2
158811
896868
936054
Returns: 4
153233
557969
263777
Returns: 0
290627
605822
933995
Returns: 4
411603
27436
739908
Returns: 0
603961
200632
353991
Returns: 4
564683
469069
290327
Returns: 1
384868
580431
314308
Returns: 2
776606
83651
499807
Returns: 3
280709
824976
187984
Returns: 0
107546
569206
152296
Returns: 2
414410
764732
588420
Returns: 1
319332
154221
142952
Returns: 4
481917
472090
196590
Returns: 1
299539
822443
757777
Returns: 1
260963
289529
356427
Returns: 0
914792
151664
66743
Returns: 5
597729
192907
308203
Returns: 1
64485
411297
214282
Returns: 4
659718
132532
906258
Returns: 2
515610
187539
456678
Returns: 5
348042
343753
577784
Returns: 4
532883
262988
332234
Returns: 3
996459
995938
219542
Returns: 1
832636
892666
847576
Returns: 0
112314
890957
950641
Returns: 3
982693
2088
193151
Returns: 5
880581
262855
118755
Returns: 0
239441
825312
387471
Returns: 4
84376
557776
46113
Returns: 5
361278
333833
39063
Returns: 5
766863
429151
598214
Returns: 2
468082
929251
159024
Returns: 4
899227
379516
642432
Returns: 3
815618
479529
780008
Returns: 4
623666
468883
812395
Returns: 4
818018
249452
26136
Returns: 1
200000
200000
972578
Returns: 6
999999
999999
1
Returns: 0
23416
91873
413457
Returns: 3
0
0
987654
Returns: 5