結果
問題 |
No.390 最長の数列
|
ユーザー |
|
提出日時 | 2016-07-18 13:00:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 579 bytes |
コンパイル時間 | 141 ms |
コンパイル使用メモリ | 22,272 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 15:34:00 |
合計ジャッジ時間 | 2,586 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 3 WA * 1 RE * 11 |
コンパイルメッセージ
main.cpp: In function ‘void init()’: main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:10:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | for (int i=0; i<N; i++) scanf("%d", x + i); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h> #define MAX_N 100000 int N; int d[MAX_N] = {0}; int x[MAX_N]; void init(){ scanf("%d", &N); for (int i=0; i<N; i++) scanf("%d", x + i); for (int i=0; i<N; i++) d[x[i]] = 1; } int main() { int max = 0; init(); for (int i=0; i<MAX_N; i++) { if (d[i] == 0) continue; int cnt = 1; for (int j=i+i; j<MAX_N; j+=i) { if (d[j] == 1) { d[j] = 0; i = j; cnt++; } } max = (max > cnt) ? max : cnt; } printf("%d\n", max); }