ÀÂÒ
Language:

Remote Training on Programming

Problems On-line status Contests FAQ
For authors:
Register  ||  Login
 
Hello, Guest! Login or register.

888. Numbers

Time Limit: 1 seconds
Memory Limit:32768KB
Points:10
View Problem Statistics Submit Problem added Administrator

Suppose we are given two numbers X and Y. We will append digits («0», «1», …«9») to X (at the end) until the resulting number is divisible by Y.

Example. Let X=13, Y=666. After appending digits 3 and 2 to X we have number 1332, which is divisible by 666.

Write a program to determine the minimum number of digits that is required to transform X into a number divisible by Y by appending digits on the right.

Limitations

1 <= X, Y <= 1 000 000 000.

Input

The first line contains the original numbers X and Y.

Output

A single integer – the minimum number of digits to be appended to X – must be written to the output file.

Sample

Standard input

Standard output

13 666

2

 


View Problem Statistics Submit Author/source:
Sorted Problems / Mathematics / Theory of numbers /
482. Multiple with equal digits 888. 468. Power 881. Prime numbers on interval 879. Sequence strikes back!
Problems from Contests / ACM Contests / Rybinsk-2010 /
887. B - Beads game 888. 889. D - Bubble 890. E - Maze 891. F - Tree packing
We can all benefit by doing occasional "toy" programs, when artificial restrictions are set up, so that we are forced to push our abilities to the limit. The art of tackling miniproblems with all our energy will sharpen our talents for the real problems. Donald E. Knuth.
time generating 0.53 sec.
© Copyright VSTU, AVT, Nosov D.A.