結果
問題 | No.390 最長の数列 |
ユーザー |
![]() |
提出日時 | 2018-04-15 20:53:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 59 ms / 5,000 ms |
コード長 | 379 bytes |
コンパイル時間 | 122 ms |
コンパイル使用メモリ | 22,912 KB |
実行使用メモリ | 6,400 KB |
最終ジャッジ日時 | 2024-06-27 00:07:34 |
合計ジャッジ時間 | 1,071 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | int N; scanf ("%d",&N); | ~~~~~~^~~~~~~~~ main.cpp:9:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | int x; scanf ("%d",&x); | ~~~~~~^~~~~~~~~
ソースコード
#include <stdio.h> int N,X[100100],D[1001001]; bool C[1001001]; int main() { int N; scanf ("%d",&N); for (int i=0;i<N;i++){ int x; scanf ("%d",&x); C[x] = 1; } int ans = 0; for (int i=1;i<=1000000;i++) if (C[i]){ D[i]++; if (ans < D[i]) ans = D[i]; for (int j=i*2;j<=1000000;j+=i) if (C[j] && D[j] < D[i]) D[j] = D[i]; } printf ("%d\n",ans); return 0; }