# LeetCode - 2110. Number of Smooth Descent Periods of a Stock ### 題目網址:https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock/ ###### tags: `LeetCode` `Medium` `動態規劃(Dynamic Programming)` ```cpp= /* -LeetCode format- Problem: 2110. Number of Smooth Descent Periods of a Stock Difficulty: Medium by Inversionpeter */ static const auto Initialize = []{ ios::sync_with_stdio(false); cin.tie(nullptr); return nullptr; }(); class Solution { public: long long getDescentPeriods(vector<int>& prices) { long long total = 1, nowLength = 1; for (int i = 1; i != prices.size(); ++i) { if (prices[i] + 1 != prices[i - 1]) nowLength = 0; ++nowLength; total += nowLength; } return total; } }; ```