Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
362 B
2
Indexable
Never
        int prev = nums.back();
        long long count = 0;
        for(int i = nums.size() - 2; i >= 0; --i)
        {
            long long cur = nums[i];
            // Since num >= 1, div is never zero
            int div = (cur - 1) / prev + 1;
            count += div - 1;
            prev = cur / div;
        }
        
        return count;