結果

問題 No.390 最長の数列
ユーザー tailstails
提出日時 2020-10-23 10:19:25
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 452 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 30,080 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 09:52:57
合計ジャッジ時間 1,065 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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:29:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   29 |         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:29:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   29 |         printf("%d",z+e[1]);
      |         ^~~~~~
main.c:29:9: note: include '<stdio.h>' or provide a declaration of 'printf'

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

char*mmap();
char e[1000001];
char t[1000001];

main(){
	char*r=mmap(0,800*1024,1,2,0,0);
	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]);
}
0