結果

問題 No.1514 Squared Matching
ユーザー tailstails
提出日時 2021-05-24 12:21:32
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 69 ms / 4,000 ms
コード長 905 bytes
コンパイル時間 1,009 ms
コンパイル使用メモリ 32,640 KB
実行使用メモリ 7,560 KB
最終ジャッジ日時 2024-04-20 22:00:20
合計ジャッジ時間 2,464 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 65 ms
7,456 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 13 ms
5,376 KB
testcase_08 AC 62 ms
7,272 KB
testcase_09 AC 54 ms
6,528 KB
testcase_10 AC 57 ms
6,912 KB
testcase_11 AC 59 ms
7,292 KB
testcase_12 AC 63 ms
7,304 KB
testcase_13 AC 64 ms
7,424 KB
testcase_14 AC 64 ms
7,420 KB
testcase_15 AC 69 ms
7,424 KB
testcase_16 AC 66 ms
7,520 KB
testcase_17 AC 61 ms
7,560 KB
testcase_18 AC 65 ms
7,384 KB
testcase_19 AC 65 ms
7,524 KB
testcase_20 AC 64 ms
7,416 KB
testcase_21 AC 64 ms
7,424 KB
testcase_22 AC 12 ms
5,376 KB
testcase_23 AC 25 ms
5,376 KB
testcase_24 AC 39 ms
5,376 KB
testcase_25 AC 51 ms
6,272 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:11:1: warning: return type defaults to 'int' [-Wimplicit-int]
   11 | main(){
      | ^~~~
main.c: In function 'main':
main.c:50:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   50 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:51:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   51 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

char*mmap();
#define rd(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

#define wt_rev(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);}

unsigned long vis[50000000/64+4];

main(){
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	rd(n);
	long res=0;

	long n9=n/9+1;
	for(long i=1;i<n9;++i){
		if(!(vis[i>>6]&1ul<<i)){
			long count=1;
			for(int j=2,ijj;ijj=i*j*j,ijj<=n;++j){
				vis[ijj>>6]|=1ul<<ijj;
				count+=1;
			}
			res+=count*count;
		}
	}

	long n4=n/4+1;
	for(long i=n9;i<n4;++i){
		if(!(vis[i>>6]&1ul<<i)){
			int ijj=i*4;
			vis[ijj>>6]|=1ul<<ijj;
			res+=4;
		}
	}

	if(n4&63){
		vis[n4>>6]|=~0ul>>-n4;
	}
	vis[n+1>>6]|=~0ul<<n+1;

	long e=(n>>6)+1;
	res+=e-(n4>>6)<<6;
	for(long i=n4>>6;i<e;++i){
		res-=__builtin_popcountl(vis[i]);
	}

	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt_rev(res);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}

0