結果
| 問題 |
No.390 最長の数列
|
| ユーザー |
tails
|
| 提出日時 | 2020-10-22 20:01:50 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 5,000 ms |
| コード長 | 464 bytes |
| コンパイル時間 | 853 ms |
| コンパイル使用メモリ | 29,824 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-21 09:29:42 |
| 合計ジャッジ時間 | 2,482 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
コンパイルメッセージ
main.c:8:1: warning: return type defaults to 'int' [-Wimplicit-int]
8 | main(){
| ^~~~
main.c: In function 'main':
main.c:9:9: warning: implicit declaration of function 'read' [-Wimplicit-function-declaration]
9 | read(0,rbuf,sizeof rbuf);
| ^~~~
main.c:30:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
30 | printf("%d",z+e[1]);
| ^~~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf'
+++ |+#include <stdio.h>
1 | #pragma GCC optimize("Ofast")
main.c:30:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
30 | printf("%d",z+e[1]);
| ^~~~~~
main.c:30:9: note: include '<stdio.h>' or provide a declaration of 'printf'
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
char rbuf[800000];
char e[1000001];
char t[1000001];
main(){
read(0,rbuf,sizeof rbuf);
char*r=rbuf;
int c;
int n=0;
while(c=*r++-48,c>=0)n=10*n+c;
while(n--){
int x=0;
while(c=*r++-48,c>=0)x=10*x+c;
e[x]=1;
}
int z=0;
for(int x=2;x<=1000000;++x){
if(e[x]){
int tx=t[x]+1;
if(z<tx) z=tx;
for(int y=x;(y+=x)<=1000000;){
if(t[y]<tx) t[y]=tx;
}
}
}
printf("%d",z+e[1]);
}
tails