結果

問題 No.390 最長の数列
ユーザー itezpace
提出日時 2016-07-09 00:39:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 526 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 164,464 KB
実行使用メモリ 10,656 KB
最終ジャッジ日時 2024-10-13 07:53:58
合計ジャッジ時間 7,771 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 1 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> v;
int m;

void rec(int i, int c){
  if(i==0){
    return;
  }
  for(int j=i-1; j>=0; --j){
    if(v[i]%v[j]==0){
      int d;
      d=c;
      d++;
      if(d>m){
        m=d;
      }
      rec(j,d);
    }
  }
}

int main(){
  int n,x;
  cin>>n;
  for(int i=0; i<n; ++i){
    cin>>x;
    v.push_back(x);
  }
  sort(v.begin(),v.end());
  m=1;
  int c;
  for(int i=v.size()-1; i>0; --i){
    c=1;
    rec(i,c);
  }
  cout<<m<<endl;
  return 0;
}
0