2020-2021:teams:manespace:codeforc_round_641_div2_problem_b
Orac and Models
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 <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector <int> 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();
}
2020-2021/teams/manespace/codeforc_round_641_div2_problem_b.txt · 最后更改: 2020/05/15 18:31 由 quantumbolt