結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-07-18 12:55:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 586 bytes |
| コンパイル時間 | 103 ms |
| コンパイル使用メモリ | 22,144 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-15 15:33:54 |
| 合計ジャッジ時間 | 2,740 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 4 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("max is %d\n", max);
}