結果

問題 No.390 最長の数列
ユーザー ei1333333ei1333333
提出日時 2016-07-08 22:35:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 338 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 158,032 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-21 06:02:22
合計ジャッジ時間 3,741 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 3 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 324 ms
5,376 KB
testcase_06 AC 232 ms
7,424 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 170 ms
7,552 KB
testcase_14 WA -
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 17 ms
7,296 KB
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%d", &N);
      |   ~~~~~^~~~~~~~~~
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%d", &X);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

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

int N;
int dp[1000001];

int main()
{  
  scanf("%d", &N);
  while(N--) {
    int X;
    scanf("%d", &X);
    for(int j = 1; j * j <= X; j++) {
      if(X % j == 0) {
        dp[X] = max(dp[X], max(dp[j], dp[X / j]) + 1);
      }
    }
  }
  cout << *max_element(dp, dp + 1000001) << endl;
}
0