結果

問題 No.979 Longest Divisor Sequence
ユーザー snow39snow39
提出日時 2020-01-31 21:58:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 736 bytes
コンパイル時間 888 ms
コンパイル使用メモリ 94,236 KB
実行使用メモリ 6,916 KB
最終ジャッジ日時 2023-10-17 09:40:05
合計ジャッジ時間 3,837 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 51 ms
5,788 KB
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int dp[300030];

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  for(int i=0;i<N;i++){
    ll val=A[i];
    for(ll i=1;i*i<=val;i++){
      if(i!=val) dp[A[i]]=max(dp[A[i]],dp[i]+1);
      if(val/i!=val) dp[A[i]]=max(dp[A[i]],dp[val/i]+1);
    }
    dp[A[i]]=max(dp[A[i]],1);
  }

  int ans=1;
  for(int i=1;i<=300010;i++) ans=max(ans,dp[i]);
  cout<<ans<<endl;

  return 0;
}
0