結果
問題 |
No.390 最長の数列
|
ユーザー |
|
提出日時 | 2019-10-12 06:33:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 342 ms / 5,000 ms |
コード長 | 395 bytes |
コンパイル時間 | 551 ms |
コンパイル使用メモリ | 63,744 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-11-27 05:09:24 |
合計ジャッジ時間 | 3,287 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; int N; int dp[1<<20]; bool exs[1<<20]; int ans; int max(int a,int b){return a<b?b:a;} main() { cin>>N; for(int i=0;i<N;i++) { int s;cin>>s;exs[s]=1; } for(int i=1;i<1<<20;i++) { if(!exs[i])continue; for(int j=1;j*j<=i;j++) { if(i%j==0) { dp[i]=max(dp[i],max(dp[j],dp[i/j])+1); } } ans=max(ans,dp[i]); } cout<<ans<<endl; }