In MI Intelligent Warehouse, there are $n_{}$ products, where the $i_{}$-th product is of size $a_i$. We always need to box producsts into all kinds of containers, and it will be safer and more cost efficient(效率高的) if for any two sizes of products, one is the other’s multiple, since(因为) there won’t be any residual(残余的) room in one container. So for each boxing we need to choose some products that for any two chosen products, either $a_i$ is multiple of $a_j$ or $a_j$ is multiple of $a_i$. Print the maximum number of products that can be chosen in one boxing.
constexprint N=1e7; int dp[N+10],mp[N+10]; voidsolve(){ int n;cin>>n; for(int i=0;i<n;i++){ int x;cin>>x; mp[x]++; } int ans=0; for(int i=1;i<=N;i++){ if(mp[i]){ dp[i]+=mp[i]; for(int j=i*2;j<=N;j+=i){ dp[j]=max(dp[i],dp[j]); } ans=max(ans,dp[i]); } } cout<<ans; }
B Intelligent Robot
C Smart Browser
Topic
In some social platforms(社交平台), there are some netizen(平台) who like to post “www“. Since the string is like the grass(草), which contains plenty of “/\“ shapes, so there are also some netizen who post “grass“.
As a fast, smart, and convenient browser, MI Browser can recognize this kind of text and show some special effects. Specifically(具体来说), given a string, MI Browser will determine(确定) the number of “/\“ shapes made by character “w“, where “w“ itself and the gap(间隙) between two adjacent(相邻的) “w“s both give one `/\` shape. If still not clear, please turn to sample input/output for more details.
As a MI fan, you want to detect(探究) the relationship between the special effects and the number of “/\“ shapes, so the thing you should do first is to determine the number of “/\“ shapes by yourself.