2992. Number of Self-Divisible Permutations
Given an integer
n
, return the number of permutations of the 1-indexed arraynums = [1, 2, ..., n]
, such that it’s self-divisible.A 1-indexed array
a
of lengthn
is self-divisible if for every1 <= i <= n
,gcd(a[i], i) == 1
.A permutation of an array is a rearrangement of the elements of that array, for example here are all of the permutations of the array
[1, 2, 3]
:
[1, 2, 3]
[1, 3, 2]
[2, 1, 3]
[2, 3, 1]
[3, 1, 2]
[3, 2, 1]
1 | int dp[1<<13]; |