Skip to content

Commit 19fe800

Browse files
authored
feat: add python3 solution to lc problem: No.2992
如果对于每个 1 <= i <= n,满足 gcd(a[i], i) == 1,数组 nums 就是 自整除 的。
1 parent 7bfc65a commit 19fe800

File tree

1 file changed

+2
-2
lines changed
  • solution/2900-2999/2992.Number of Self-Divisible Permutations

1 file changed

+2
-2
lines changed

solution/2900-2999/2992.Number of Self-Divisible Permutations/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class Solution:
108108
return 1
109109
ans = 0
110110
for j in range(1, n + 1):
111-
if (mask >> j & 1) == 0 and (i % j == 0 or j % i == 0):
111+
if (mask >> j & 1) == 0 and gcd(i,j)==1:
112112
ans += dfs(mask | 1 << j)
113113
return ans
114114

@@ -267,7 +267,7 @@ class Solution:
267267
for mask in range(1 << n):
268268
i = mask.bit_count()
269269
for j in range(1, n + 1):
270-
if (mask >> (j - 1) & 1) == 1 and (i % j == 0 or j % i == 0):
270+
if (mask >> (j - 1) & 1) == 1 and gcd(i,j)==1:
271271
f[mask] += f[mask ^ (1 << (j - 1))]
272272
return f[-1]
273273
```

0 commit comments

Comments
 (0)