ÀÂÒ
Language: Russian
English

Remote Training on Programming

Problems Online status Contests
News FAQ E-learning
For authors:
Register  ||  Login
 
Hello, Guest! Please login or register.

888. Numbers

Time Limit: 1 seconds
Memory Limit:65536KB
Points:100
View Problem Statistics Submit Problem added debug

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 Problem discussion Author/source:
Sorted Problems / Mathematics / Theory of numbers /
482. Multiple with equal digits 888. 467. Pipeline 468. Power 134. Prime Numbers
Problems from Contests and Camps / World Championship in Programming (ICPC) / Rybinsk-2010 /
887. B - Beads game 888. 889. D - Bubble 890. E - Maze 891. F - Tree packing
time generating 0.375 sec.
© Copyright VSU, AVT, Nosov D.A., Andrianov I.A.