===== B ===== * 题意:给你一串数$s$$1$,$s$$2$,$s$$3$,$\ldots$,$s$$n$. 如果满足下标$i$$j$,$i$$j+1$满足$i$$j$<$i$$j+1$并且有$s$$i$$j$ <$s$$i$$j+1$ .则称这样的安排是美的,题目要你找出一串序列中最长的,具有美感的数列长度。 * 代码: # include using namespace std; void solve() { int n; cin >> n; vector a(n + 1), dp(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } int answer = 0; for (int i = 1; i <= n; i++) { int mx = 0; for (int j = 1; j * j <= i; j++) { if (i % j == 0) { if (a[j] < a[i]) mx = max(mx, dp[j]); if (a[i / j] < a[i]) mx = max(mx, dp[i / j]); } } dp[i] = mx + 1; answer = max(answer, dp[i]); } cout << answer << endl; } int main() { int tt = 1; cin >> tt; while (tt--) solve(); }