結果

問題 No.979 Longest Divisor Sequence
ユーザー どららどらら
提出日時 2020-01-31 23:12:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 913 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 176,104 KB
実行使用メモリ 15,580 KB
最終ジャッジ日時 2023-10-17 12:17:29
合計ジャッジ時間 5,747 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,244 KB
testcase_01 AC 19 ms
8,544 KB
testcase_02 AC 27 ms
9,336 KB
testcase_03 AC 15 ms
8,092 KB
testcase_04 AC 51 ms
15,580 KB
testcase_05 AC 25 ms
9,072 KB
testcase_06 AC 29 ms
10,128 KB
testcase_07 AC 27 ms
9,336 KB
testcase_08 AC 51 ms
15,580 KB
testcase_09 AC 29 ms
9,864 KB
testcase_10 AC 6 ms
4,460 KB
testcase_11 AC 8 ms
4,984 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;

  unordered_map<int,int> m;
  int ret = 1;
  rep(i,N){
    int a;
    cin >> a;

    if(m.count(a) == 0){
      int p = 2;
      while(p*a<=300000){
        if(m.count(p*a) == 0){
          m[p*a] = 2;
        }
        p++;
      }
    }else{
      ret = max(ret, m[a]);
      int p = 2;
      while(p*a<=300000){
        if(m.count(p*a) == 0){
          m[p*a] = m[a]+1;
        }else{
          if(m[p*a] < m[a]+1){
            m[p*a] = m[a]+1;
          }
        }
        p++;
      }
    }
  }

  cout << ret << endl;
  
  return 0;
}

0