結果

問題 No.1514 Squared Matching
ユーザー tailstails
提出日時 2021-05-22 11:15:24
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 67 ms / 4,000 ms
コード長 774 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 32,512 KB
実行使用メモリ 7,496 KB
最終ジャッジ日時 2024-04-18 17:33:36
合計ジャッジ時間 1,877 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,816 KB
testcase_01 AC 64 ms
7,484 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 14 ms
6,940 KB
testcase_08 AC 63 ms
7,216 KB
testcase_09 AC 56 ms
6,944 KB
testcase_10 AC 57 ms
6,940 KB
testcase_11 AC 61 ms
7,128 KB
testcase_12 AC 67 ms
7,400 KB
testcase_13 AC 63 ms
7,336 KB
testcase_14 AC 62 ms
7,356 KB
testcase_15 AC 62 ms
7,496 KB
testcase_16 AC 63 ms
7,436 KB
testcase_17 AC 62 ms
7,464 KB
testcase_18 AC 61 ms
7,492 KB
testcase_19 AC 66 ms
7,468 KB
testcase_20 AC 64 ms
7,376 KB
testcase_21 AC 63 ms
7,420 KB
testcase_22 AC 13 ms
6,940 KB
testcase_23 AC 27 ms
6,944 KB
testcase_24 AC 37 ms
6,944 KB
testcase_25 AC 51 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:11:1: warning: return type defaults to 'int' [-Wimplicit-int]
   11 | main(){
      | ^~~~
main.c: In function 'main':
main.c:41:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   41 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:42:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   42 |         _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 n4=n/4+1;
	for(long i=1;i<n4;++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;
		}
	}

	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