-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1350b.cpp
More file actions
47 lines (34 loc) · 773 Bytes
/
Copy path1350b.cpp
File metadata and controls
47 lines (34 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> a(n + 2), dp(n + 2);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= sqrt(i); j++) {
if (i % j == 0) {
if (a[j] < a[i]) {
dp[i] = max(dp[i], dp[j] + 1);
}
if (a[i / j] < a[i]) {
dp[i] = max(dp[i], dp[i / j] + 1);
}
}
}
ans = max(ans, dp[i]);
}
cout << ans + 1 << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
}