A naive thought, buckets[i] to store all divisors and multiples of index i,
then do backtrack to accumulate the number of the beautiful arrangements.
can be improved in time by memorization, by cost of space.
for example, use a N-bit integer K to denote the appearance of numbers. and a map
where count is the number of beautiful arrangements of length L from numbers that appear in K.