0
已解决
曹博扬
初级天翼
初级天翼
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[3000005],ans;
int f[3000005];
int b[10000005];
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
b[a[i]]++;
}
sort(a+1,a+n+1);
for(int i=1;i<=n;i++){
f[i]=1;
//cout<<a[i]<<" ";
for(int j=1;j<i;j++){
if(a[i]%a[j]==0){
//cout<<a[j]<<" ";
f[i]=max(f[i],f[j]+1);
}
}
//cout<<endl;
ans=max(ans,f[i]);
}
cout<<ans;
return 0;
}
60分TLE解法,求如何优化