Codeforces 1350 B. Orac and Models(DP)_最长子序列

题意:

求一个下标单调递增且互为倍数,且满足若 Codeforces 1350 B. Orac and Models(DP)_最长子序列_02,则 Codeforces 1350 B. Orac and Models(DP)_最长子序列_03的最长子序列。

简单 Codeforces 1350 B. Orac and Models(DP)_最长子序列_04

AC代码;

const int N = 2e5 + 10;
int n, m, k;
int cnt, res, pos, ans;
int a[N], dp[N];

int main()
{
int t;
sd(t);
while (t--)
{
sd(n);
rep(i, 1, n)
sd(a[i]);
rep(i, 1, n)
dp[i] = 1;
ans = 1;
per(i, n, 1)
{
dp[i] = 1;
rep(j, 1, n)
{
if (i * j > n)
break;
if (a[i] < a[i * j])
dp[i] = max(dp[i], 1 + dp[i * j]);
}
ans = max(ans, dp[i]);
}
pd(ans);
}
return 0;
}