Spaces:
Sleeping
Sleeping
You are given a positive integer n.Find a permutation† p of length n such that there do not exist two distinct indices i and j (1≤i,j<n; i≠j) such that pi divides pj and pi+1 divides pj+1.Refer to the Notes section for some examples.Under the constraints of this problem, it can be proven that at least one p exists.† A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array), and [1,3,4] is also not a permutation (n=3 but there is 4 in the array). |