結果

問題 No.1514 Squared Matching
ユーザー tailstails
提出日時 2021-05-22 11:09:14
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 73 ms / 4,000 ms
コード長 752 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 32,768 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-18 17:32:48
合計ジャッジ時間 2,282 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 70 ms
7,424 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 14 ms
5,376 KB
testcase_08 AC 67 ms
7,168 KB
testcase_09 AC 57 ms
6,400 KB
testcase_10 AC 64 ms
6,912 KB
testcase_11 AC 69 ms
7,168 KB
testcase_12 AC 70 ms
7,388 KB
testcase_13 AC 71 ms
7,360 KB
testcase_14 AC 72 ms
7,552 KB
testcase_15 AC 71 ms
7,360 KB
testcase_16 AC 73 ms
7,388 KB
testcase_17 AC 72 ms
7,552 KB
testcase_18 AC 71 ms
7,544 KB
testcase_19 AC 73 ms
7,524 KB
testcase_20 AC 70 ms
7,464 KB
testcase_21 AC 72 ms
7,364 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 AC 29 ms
5,376 KB
testcase_24 AC 44 ms
5,376 KB
testcase_25 AC 57 ms
6,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:11:1: warning: return type defaults to 'int' [-Wimplicit-int]
   11 | main(){
      | ^~~~
main.c: In function 'main':
main.c:40:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   40 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:41:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   41 |         _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;
	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