We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7bfc65a commit 19fe800Copy full SHA for 19fe800
solution/2900-2999/2992.Number of Self-Divisible Permutations/README.md
@@ -108,7 +108,7 @@ class Solution:
108
return 1
109
ans = 0
110
for j in range(1, n + 1):
111
- if (mask >> j & 1) == 0 and (i % j == 0 or j % i == 0):
+ if (mask >> j & 1) == 0 and gcd(i,j)==1:
112
ans += dfs(mask | 1 << j)
113
return ans
114
@@ -267,7 +267,7 @@ class Solution:
267
for mask in range(1 << n):
268
i = mask.bit_count()
269
270
- if (mask >> (j - 1) & 1) == 1 and (i % j == 0 or j % i == 0):
+ if (mask >> (j - 1) & 1) == 1 and gcd(i,j)==1:
271
f[mask] += f[mask ^ (1 << (j - 1))]
272
return f[-1]
273
```
0 commit comments