Barcodes P57443


Statement
 

pdf   zip

html

Nowadays, most companies use barcodes like the following one to distinguish their products.

The most spread code which tends to become a standard is the EAN-13. This code is formed by 13 digits: the 12 first correspond to the code of the product, and the last one is a digit of control. The digit of control is a very important part of the EAN coding, because it makes possible the elimination of the reading errors.

The digit of control is computed in two steps:

  1. We multiply by 3 the numbers which are in odd positions and we add up the result with the numbers which are in even position. (The digits are numbered from right to left.)
  2. We substract to the result the nearest equal or greater tens.

For instance, the digit of control corresponding to code 544900000099 is computed like this:

  1. 9*3+9+0*3+0+0*3+0+0*3+0+9*3+4+4*3+5 = 84
  2. 90−84 = 6

Therefore, its digit of control is 6.

Input

Input is a sequence of numbers with 12 digits each one corresponding to different codes of products.

Output

For each product, print in a line the original code plus its digit of control.

Observation

Warning: int type may not be enough to store numbers with 12 digits.

Public test cases
  • Input

    544900000099
    438763762897
    239872879478
    009234464800
    

    Output

    5449000000996
    4387637628972
    2398728794782
    0092344648000
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++