結果
| 問題 | No.390 最長の数列 |
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2017-04-27 13:47:33 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 5,000 ms |
| コード長 | 528 bytes |
| 記録 | |
| コンパイル時間 | 274 ms |
| コンパイル使用メモリ | 21,504 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-02 12:10:06 |
| 合計ジャッジ時間 | 1,125 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
コンパイルメッセージ
main.c: In function ‘run’:
main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d",&n);
| ^~~~~~~~~~~~~~
main.c:14:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d",&x);
| ^~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
void run(void){
int n;
scanf("%d",&n);
const int m=1000000;
int *e=(int *)calloc(m+1,sizeof(int));
int i;
for(i=0;i<n;i++){
int x;
scanf("%d",&x);
e[x]++;
}
for(i=m/2;i>=1;i--){
if(e[i]>0){
int j;
for(j=2*i;j<=m;j+=i){
e[i]=MAX(e[i],e[j]+1);
}
}
}
int ans=0;
for(i=1;i<=m;i++){
ans=MAX(ans,e[i]);
}
printf("%d\n",ans);
free(e);
return;
}
int main(void){
run();
return 0;
}
akakimidori