Rotational division numbers
Statement
Given a positive integer [[k]], a rotational division number associated with [[k]] is a positive integer [[n]] such that:
- the foremost digits of [[n]] are [[k]],
- [[n]] is divisible by [[k]], and
- upon division by [[k]], the quotient is also [[n]], except the [[k]] is now at the end of [[n]].
For example, if [[k]] = {{4}}, then [[n]] = {{410256}} satisfies, as `410256/4=102564`and if [[k]] = {{19}}, then [[n]] = {{190100052659294365455502896261}} satisfies, as `190100052659294365455502896261/19=010005265929436545550289626119`
Note that we let leading zeroes be allowed. The task is for given [[k]], give the length [[l]] of the smallest rotational division number [[n]] associated with [[k]].
Input description
<<Line 1:>> A positive integer [[k]].
Output description
<<Line 1:>> A positive integer [[l]].
Constraints
1 ≤ [[k]] ≤ 1000
A rotational division number [[n]] is guaranteed to exist for each [[k]].
Game modes
Test cases
Test 1 Test
Input
4
Output
6
Validator 1 Validator
Input
1
Output
1
Test 2 Test
Input
19
Output
30
Validator 2 Validator
Input
3
Output
28
Test 3 Test
Input
9
Output
44
Validator 3 Validator
Input
6
Output
58
Test 4 Test
Input
12
Output
108
Validator 4 Validator
Input
13
Output
432
Test 5 Test
Input
14
Output
1398
Validator 5 Validator
Input
20
Output
1998
Test 6 Test
Input
54
Output
5398
Validator 6 Validator
Input
69
Output
6898
Test 7 Test
Input
101
Output
50499
Validator 7 Validator
Input
108
Output
161997
Test 8 Test
Input
215
Output
303504
Validator 8 Validator
Input
446
Output
333498
Test 9 Test
Input
603
Output
904497
Validator 9 Validator
Input
669
Output
1003497
Test 10 Test
Input
989
Output
2028
Validator 10 Validator
Input
990
Output
1484997
Test 11 Test
Input
223
Output
210
Validator 11 Validator
Input
209
Output
408
Solution language
Solution
Stub generator input