Log inSign up
Problems / B005

Four lines on the order form

200 ptsCases 15Set by dongbinna
Added October 30.

Statement

A print shop uses A drops of ink for every poster it prints. When an order comes in, the clerk writes four lines on the order form to judge how much ink to prepare. The order quantity B is always written as a three-digit number, and the quantity field on the form is split into a hundreds slot, a tens slot and a ones slot.

The clerk reads the digits in the quantity field one at a time and writes the digit times A on each line going down. The writing starts from the rightmost slot, so the ones slot comes first and the tens slot and the hundreds slot come after it. The last line, the fourth, holds the number of ink drops needed to print the whole order. The four lines mean the following.

1) First line: the digit in the ones slot times A 2) Second line: the digit in the tens slot times A 3) Third line: the digit in the hundreds slot times A 4) Fourth line: the number of ink drops needed to print all B posters of the order

Write a program that prints the four lines the clerk writes, in order, when the number of ink drops for one poster A and the order quantity B are given.

For example, suppose A=472 drops and B=385 posters. The quantity field on the form is then filled in as in the following table.

SlotHundredsTensOnes
Digit385

The values on the four lines the clerk writes are then as in the following table.

LineFirstSecondThirdFourth
Slot usedOnesTensHundredsWhole order
Calculation472 times 5472 times 8472 times 3472 times 385
Value236037761416181720

So in this case 2360, 3776, 1416 and 181720 are printed in that order over four lines.

Putting the results for other orders into one table gives the following. When the digit in a slot is 0, the value on that line is 0 as well.

ABFirstSecondThirdFourth
472385236037761416181720
3232061938064666538
1123321123

Input and output examples

Example 1

Input

472
385

Output

2360
3776
1416
181720

Example 2

Input

323
206

Output

1938
0
646
66538

Example 3

Input

1
123

Output

3
2
1
123

Input

  • First the number of ink drops for one poster A is given as a natural number on the first line. A is a natural number from 1 to 999. Next the order quantity B is given as a natural number on the second line. B is a three-digit natural number from 100 to 999. So the hundreds digit of B is from 1 to 9, while the tens digit and the ones digit can be 0. B is never given with two digits or with four digits. The two numbers are given on separate lines, not together on one line.

Output

  • Print the four values one per line, over four lines in all, in order. Print the value for the ones slot on the first line, the value for the tens slot on the second line and the value for the hundreds slot on the third line, and print the number of ink drops for the whole order on the fourth line. On a line whose slot digit is 0, the line is not left empty, it prints 0. Each line holds one number only, and no space is attached after the number.

Requirements

  • The input is two lines, with one number per line
  • A is a natural number from 1 to 999
  • B is a three-digit natural number from 100 to 999
  • The order of the four lines is ones slot, tens slot, hundreds slot, whole order
  • A line whose slot digit is 0 still prints 0
  • You must write a program that reads from standard input and writes to standard output
  • Trailing spaces at the end of a line and blank lines at the end of the output are ignored when grading
  • The languages you can use are Python and JavaScript
  • The memory limit is 256MB. The browser does not measure it, it only states it
  • The time limit is set by measuring the setter's reference solution on the same runtime
  • On this problem you submit code, not a prompt. That code runs in the browser on this device, and all that goes to the server is a fingerprint of the output and the time it took. Whether it is correct is decided by the server. The run time is a number each device reports, so the code and the device details are posted next to it on the leaderboard.
  • The output has to match the expected value down to the character. A space inside a line counts the same as any other character.
  • There are 15 cases, and 3 of them show the input together with the expected output. The rest are used only when you submit and are not shown on this page.
  • You have to pass all 15 cases to solve this.
Read the requirements carefully before solving. Tampering with the grading to make a submission look like a pass can get you sanctioned if caught. The code you submit is published on the leaderboard along with the result.

Examples

3 public cases. Judging also uses hidden cases. You have to pass all 15 cases to solve this.

Input
Expected output
472
385
2360
3776
1416
181720
1
123
3
2
1
123
323
206
1938
0
646
66538

Solution

Your code runs on this device. Only the fingerprint of the output and the elapsed time go to the server. The server decides whether it is correct.

0 chars1 lineMemory 256MB (recorded only)Reference 2.0ms

Submitting requires you to log in. Running against the public cases works without one.

You can test with 3 public cases. Submitting runs the hidden cases too.

People who solved this problem

Nobody yet. You could be the first.