結果

問題 No.1514 Squared Matching
ユーザー tailstails
提出日時 2021-05-21 22:58:06
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 848 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 32,000 KB
実行使用メモリ 392,100 KB
最終ジャッジ日時 2024-10-10 09:50:03
合計ジャッジ時間 9,628 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,435 ms
196,608 KB
testcase_01 TLE -
testcase_02 AC 1,419 ms
196,608 KB
testcase_03 AC 1,431 ms
196,736 KB
testcase_04 AC 1,437 ms
196,608 KB
testcase_05 AC 1,438 ms
196,608 KB
testcase_06 AC 1,480 ms
200,080 KB
testcase_07 AC 2,010 ms
235,428 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 AC 2,036 ms
237,008 KB
testcase_23 AC 2,723 ms
275,208 KB
testcase_24 AC 3,410 ms
314,416 KB
testcase_25 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:27:1: warning: return type defaults to 'int' [-Wimplicit-int]
   27 | main(){
      | ^~~~
main.c: In function 'main':
main.c:31:9: warning: implicit declaration of function 'read'; did you mean 'rd'? [-Wimplicit-function-declaration]
   31 |         read(0,rbuf,sizeof rbuf);
      |         ^~~~
      |         rd
main.c:56:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   56 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:57:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   57 |         _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;}

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


#define SIEVE_N 50000001
int sieve[SIEVE_N];
void mksieve(){
	for(int i=2;i<SIEVE_N;++i){
		if(sieve[i]==0){
			for(int j=i;j<SIEVE_N;j+=i){
				if(sieve[j]==0){
					sieve[j]=i;
				}
			}
		}
	}
}

int count[50000001];

main(){
	mksieve();

	char rbuf[64],*rp=rbuf;
	read(0,rbuf,sizeof rbuf);
	rd(n);
	
	for(int i=1;i<=n;++i){
		int j=i;
		int l=1;
		while(j>1){
			int p=sieve[j];
			j/=p;
			if(sieve[j]==p){
				j/=p;
			}else{
				l*=p;
			}
		}
		count[l]+=1;
	}

	int res=0;
	for(int i=1;i<=n;++i){
		res+=count[i]*count[i];
	}

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