3326. Minimum Division Operations to Make Array Non Decreasing
You are given an integer array
nums
.Any positive divisor of a natural number
x
that is strictly less thanx
is called a proper divisor ofx
. For example, 2 is a proper divisor of 4, while 6 is not a proper divisor of 6.You are allowed to perform an operation any number of times on
nums
, where in each operation you select any one element fromnums
and divide it by its greatest proper divisor.Return the minimum number of operations required to make the array non-decreasing.
If it is not possible to make the array non-decreasing using any number of operations, return
-1
.
Sieve of Eratosthenes
c++
1 | class Solution { |
Math
c++
1 | class Solution { |