【題解】Codeforces 1350B. Orac and Models

【題目敘述】http://codeforces.com/contest/1350/problem/B

#include <iostream>
using namespace std;
 
const int maxn = 100005;
int t, n, a[maxn], mx[maxn], ans;
 
 
int main() {
    cin >> t;
    while (t--){
        cin >> n;
        for (int i = 1; i <= n; i++){
            cin >> a[i];
        }
        ans = 0;
        for (int i = n; i > 0; i--){
            mx[i] = 1;
            for (int j = i*2; j <= n; j += i){
                if (a[i] < a[j]) mx[i] = max(mx[i], mx[j]+1);
            }
            ans = max(ans, mx[i]);
        }
        cout << ans << "\n";
    }
}
分享本文 Share with friends